travel form fixes

This commit is contained in:
2016-06-04 09:56:34 +10:00
parent cffd8836da
commit a8a9c5c43e

View File

@@ -298,7 +298,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tok
);
}
//display the medical conditions question if it is enabled
if (variable_get('booking_enable_medcond', 0) == 1) {
if (variable_get('booking_enable_medcond', 0) == 1 || $inserting == FALSE) {
$form['requirements']['booking_medical_conditions'] = array(
'#type' => 'textfield',
'#title' => t('Please describe any medical condition we need to know about.'),
@@ -353,7 +353,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tok
function travel_form_validate($form, &$form_state)
{
//watchdog('booking', "<pre>Travel form:\n@info</pre>", array('@info' => print_r( $form_state, true)));
watchdog('booking_debug', "<pre>Travel form:\n@info</pre>", array('@info' => print_r( $form_state, true)));
//verify boyfriend/girlfriend id is in the correct format
if (isset($form_state['values']['booking_bf_gf_nid']) && $form_state['values']['booking_bf_gf_nid'] != '') {
@@ -448,7 +448,7 @@ function travel_form_submit($form, &$form_state)
}
//fetch details about the person
$person = db_query("SELECT nid as personid, booking_tempid, booking_firstname, booking_lastname, booking_partner_id, booking_dietary, booking_room_mate1 " . "FROM {booking_person} " . "WHERE nid = :nid ", array(
$person = db_query("SELECT nid as personid, booking_tempid, booking_firstname, booking_lastname, booking_partner_id, booking_dietary, booking_room_mate1, booking_medical_conditions " . "FROM {booking_person} " . "WHERE nid = :nid ", array(
':nid' => $values['personid']
))->fetchObject();
@@ -481,10 +481,10 @@ function travel_form_submit($form, &$form_state)
//$node->booking_accom_after_staying_with = $values['booking_accom_after_staying_with'];
//booking_person related fields
$node->booking_medical_conditions = $values['booking_medical_conditions'];
$node->booking_bf_gf_nid = empty($values['booking_bf_gf_nid']) ? 0 : $values['booking_bf_gf_nid'];
//optional fields
$node->booking_medical_conditions = (variable_get('booking_enable_medcond', 0) == 1 ? $values['booking_medical_conditions'] : $person->booking_medical_conditions;
$node->booking_dietary = variable_get('booking_enable_dietary', 0) == 1 ? $values['booking_dietary'] : $person->booking_dietary;
//room mate field might be enabled but not displayed for a married couple so calculate whether the field is empty or not first
$room_mate = empty($values['booking_room_mate1']) ? $person->booking_room_mate1 : $values['booking_room_mate1'];
@@ -500,10 +500,7 @@ function travel_form_submit($form, &$form_state)
_booking_travelform_confirmation_email($values['personid']);
drupal_set_message("Thanks for submitting your travel details. You should receive a confirmation email shortly.", $type = 'status');
$form_state['redirect'] = array(
'content/travel'
);
$form_state['redirect'] = array('content/travel');
}
function travel_load($nodes)