more validation

This commit is contained in:
2017-06-29 11:51:19 +10:00
parent b0cc61de6c
commit 3d68e2a8ce

View File

@@ -122,6 +122,10 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
'#required' => TRUE,
'#default_value' => !empty($data->booking_regn_earlyaccess_code) ? $data->booking_regn_earlyaccess_code : ''
);
$form['booking_earlyaccess'] = array(
'#type' => 'hidden',
'#value' => 1
);
}
$form['your-details'] = array(
@@ -407,27 +411,10 @@ function booking_form($node, &$form_state, $inserting = FALSE, $early_access_all
//only show the booking agreement tickbox if the node is being created, since this value isn't stored anywhere
if ($inserting == TRUE) {
/*
$form['your-details']['booking_regular_cyc'] = array
(
'#type' => 'checkbox',
'#title' => t('Regularly Attend CYC '),
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
'#title' => t('I regularly attend CYC events/activities'),
); */
$form['your-details']['booking_agreement'] = array(
'#type' => 'checkbox',
'#title' => t('Aims and Expectations'),
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
/*
'#states' => array(
// Only show this field when the checkbox is unchecked.
'visible' => array(
':input[name="booking_agreement"]' => array('checked' => FALSE),
),
),
*/
'#title' => token_replace(variable_get('booking_registration_aims_rules_checkbox'), booking_define_tokens()),
'#description' => token_replace(variable_get('booking_registration_aims_rules_text'), booking_define_tokens())
);
@@ -941,9 +928,21 @@ function booking_form_validate($form, &$form_state) {
//watchdog('booking', '<pre>Booking registration form validation:\n@info</pre>', array('@info' => print_r( $data, true)));
//if necessary, validate early access code
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) {
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1 && (isset($data['booking_earlyaccess']) && $data['booking_earlyaccess'] == 1)) {
if (isset($data['booking_regn_earlyaccess_code']) && $data['booking_regn_earlyaccess_code'] != '') {
//perform a database lookup against the booking_regn_earlyaccess_codes table
$code_check = db_query("SELECT cid " .
"FROM {booking_regn_earlyaccess_codes} " .
"WHERE booking_regn_earlyaccess_code = :code AND booking_eventid = :eid AND booking_regn_earlyaccess_code_avail = 'Y'",
array(
':code' => $data['booking_regn_earlyaccess_code'],
':eid' => $event->eid,
)
)->fetchObject();
//see if we got a result
if (! $code_check) {
form_set_error('booking_regn_earlyaccess_code', t('You have entered an invalid early registration code. If you do not have a code, please wait until normal registrations open.'));
}
}
else {
form_set_error('booking_regn_earlyaccess_code', t('You must enter an early access code to register now. If you do not have a code, please wait until normal registrations open.'));