update booking form for prev sw count

This commit is contained in:
Nathan Coad
2019-09-10 10:00:09 +10:00
parent 47fcbd04f2
commit 86c4b7fcb3

View File

@@ -951,7 +951,7 @@ function booking_form($node, &$form_state, $inserting = FALSE)
$freestyle_required_check = (variable_get('booking_require_freestyle', 1) == 1) && $inserting; $freestyle_required_check = (variable_get('booking_require_freestyle', 1) == 1) && $inserting;
$form['misc-areas']['booking_freestyle_text'] = array( $form['misc-areas']['booking_freestyle_text'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t("Freestyle (optional)"), '#title' => t("Freestyle text (anything you'd like to share)"),
'#maxlength' => 500, '#maxlength' => 500,
'#required' => $freestyle_required_check, '#required' => $freestyle_required_check,
'#default_value' => !empty($data->booking_freestyle_text) ? $data->booking_freestyle_text : '' '#default_value' => !empty($data->booking_freestyle_text) ? $data->booking_freestyle_text : ''
@@ -1227,12 +1227,18 @@ function booking_form_validate($form, &$form_state) {
} }
//verify alternate guardian phone number //verify alternate guardian phone number
if (($data['booking_guardian_phone_alt'] != '') && (!_valid_phone_number($data['booking_guardian_phone_alt']))) if (($data['booking_guardian_phone_alt'] != '') && (!_valid_phone_number($data['booking_guardian_phone_alt']))) {
form_set_error('booking_guardian_phone_alt', t('You have entered an invalid alternate contact phone number for your emergency contact.')); form_set_error('booking_guardian_phone_alt', t('You have entered an invalid alternate contact phone number for your emergency contact.'));
}
//check the terms and conditions have been agreed to. Do this one last so it stands out more //check the terms and conditions have been agreed to. Do this one last so it stands out more
if ($data['booking_agreement'] == 0) if ($data['booking_agreement'] == 0) {
form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.')); form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.'));
}
if (variable_get('booking_enable_previous_studyweeks', 0) == 1 && $data['booking_prev_sw_count'] == '') {
form_set_error('booking_prev_sw_count', t('You must select the number of study weeks that you\'ve previously attended.'));
}
//if there are any errors then log the data the user entered so we can check it later //if there are any errors then log the data the user entered so we can check it later
if (form_get_errors()) { if (form_get_errors()) {
@@ -1371,6 +1377,7 @@ function booking_form_submit($form, &$form_state)
$node->booking_earlyaccess_code_id = empty($values['booking_earlyaccess_code']) ? 0 : $earlyaccess_query->cid; $node->booking_earlyaccess_code_id = empty($values['booking_earlyaccess_code']) ? 0 : $earlyaccess_query->cid;
$node->booking_song_choice = empty($values['booking_song_choice']) ? '' : $values['booking_song_choice']; $node->booking_song_choice = empty($values['booking_song_choice']) ? '' : $values['booking_song_choice'];
$node->booking_freestyle_text = empty($values['booking_freestyle_text']) ? '' : $values['booking_freestyle_text']; $node->booking_freestyle_text = empty($values['booking_freestyle_text']) ? '' : $values['booking_freestyle_text'];
$node->booking_prev_sw_count = empty($values['booking_prev_sw_count']) ? '0' : $values['booking_prev_sw_count'];
//remove newlines from these fields so the CSV output doesn't get messed up //remove newlines from these fields so the CSV output doesn't get messed up
$medical = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions']; $medical = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions'];