Various tweaks and fixes
This commit is contained in:
@@ -265,13 +265,17 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
||||
//only show the room mate field if we're allowed to
|
||||
if (variable_get('booking_enable_roommate', 0) == 1 || $inserting == FALSE)
|
||||
{
|
||||
$form['requirements']['booking_room_mate1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('I would like to share a room with'),
|
||||
'#maxlength' => 200,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : $booking_roommate,
|
||||
);
|
||||
//married people won't need to select a room mate
|
||||
if ((variable_get('booking_enable_combined_pricing', 0) == 1) && $person->booking_partner_id == 0)
|
||||
{
|
||||
$form['requirements']['booking_room_mate1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('I would like to share a room with'),
|
||||
'#maxlength' => 200,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : $booking_roommate,
|
||||
);
|
||||
}
|
||||
}
|
||||
//only show this field if this person isn't married
|
||||
if ((variable_get('booking_enable_combined_pricing', 0) == 1) && $person->booking_partner_id == 0)
|
||||
@@ -333,6 +337,51 @@ function travel_form_validate($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
//check to make sure flight info is entered if it is selected
|
||||
if (isset($form_state['values']['booking_transport_type']) && $form_state['values']['booking_transport_type'] == 'Flying')
|
||||
{
|
||||
if ( (! isset($form_state['values']['booking_flightnum_inbound'])) || ($form_state['values']['booking_flightnum_inbound'] == '') )
|
||||
{
|
||||
form_set_error('booking_flightnum_inbound',
|
||||
t('Please enter the flight number associated with your arrival flight.')
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
$form_state['values']['booking_flight_datetime_inbound']['day'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_inbound']['month'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_inbound']['year'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_inbound']['hour'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_inbound']['minute'] == ''
|
||||
)
|
||||
{
|
||||
form_set_error('booking_flight_datetime_inbound',
|
||||
t('Please enter the arrival time associated with your flight.')
|
||||
);
|
||||
}
|
||||
|
||||
if ( (! isset($form_state['values']['booking_flightnum_outbound'])) || ($form_state['values']['booking_flightnum_outbound'] == '') )
|
||||
{
|
||||
form_set_error('booking_flightnum_outbound',
|
||||
t('Please enter the flight number associated with your departing flight.')
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
$form_state['values']['booking_flight_datetime_outbound']['day'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_outbound']['month'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_outbound']['year'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_outbound']['hour'] == '' ||
|
||||
$form_state['values']['booking_flight_datetime_outbound']['minute'] == ''
|
||||
)
|
||||
{
|
||||
form_set_error('booking_flight_datetime_outbound',
|
||||
t('Please enter the departure time associated with your flight.')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function travel_form_submit($form, &$form_state) {
|
||||
@@ -387,7 +436,9 @@ function travel_form_submit($form, &$form_state) {
|
||||
|
||||
//optional fields
|
||||
$node->booking_dietary = variable_get('booking_enable_dietary', 0) == 1 ? $values['booking_dietary'] : $person->booking_dietary;
|
||||
$node->booking_room_mate1 = variable_get('booking_enable_roommate', 0) == 1 ? $values['booking_room_mate1'] : $person->booking_room_mate1;
|
||||
//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'];
|
||||
$node->booking_room_mate1 = variable_get('booking_enable_roommate', 0) == 1 ? $room_mate : $person->booking_room_mate1;
|
||||
|
||||
//watchdog('booking', "<pre>Travel data to save:\n@info</pre>", array('@info' => print_r( $node, true)));
|
||||
|
||||
|
Reference in New Issue
Block a user