perform validation
This commit is contained in:
@@ -116,6 +116,38 @@ function booking_variety_session_form_callback($form, &$form_state) {
|
||||
return $form['form']['variety-sessions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the submission
|
||||
*/
|
||||
function booking_variety_regn_form_validate($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
//watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||
|
||||
//TODO : Check that the booking number is valid for this event
|
||||
|
||||
//verify that user-entered data is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['booking_nid'])) {
|
||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
||||
}
|
||||
|
||||
// Perform lookup on barcode to make sure it matches someone attending the current event
|
||||
$db_and = db_and();
|
||||
$db_and->condition('p.booking_eventid', $event->eid, '=');
|
||||
$db_and->condition('p.booking_status', 1, '=');
|
||||
$db_and->condition('p.nid', $values['booking_nid'], '=');
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition($db_and)
|
||||
->fields('p');
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
if (! $person) {
|
||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the submission
|
||||
*/
|
||||
|
Reference in New Issue
Block a user