test
This commit is contained in:
@@ -13,9 +13,15 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
$form = array ();
|
||||
$data = $node;
|
||||
|
||||
$query = db_query("SELECT * FROM {booking_variety_times} WHERE booking_eventid = :eid AND booking_variety_status = 1",
|
||||
array(':eid' => $event->eid));
|
||||
//$query = db_query("SELECT * FROM {booking_variety_times} WHERE booking_eventid = :eid AND booking_variety_status = 1",
|
||||
// array(':eid' => $event->eid));
|
||||
|
||||
// Query the variety timeslot table
|
||||
$timeslot_query = db_select('booking_variety_times', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
->fields('v')
|
||||
->orderBy('v.booking_variety_start');
|
||||
$result = $timeslot_query->execute();
|
||||
|
||||
$form['booking_variety_regn_feedback_wrapper'] = array(
|
||||
'#markup' => '<div id="booking_variety_regn_feedback_wrapper" class="form-item">Please enter your booking number from your lanyard.</div>',
|
||||
@@ -28,27 +34,31 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
'#default_value' => !empty($data->booking_nid) ? $data->booking_nid : '',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_variety_regn_feedback_wrapper',
|
||||
'callback' => 'booking_variety_regn_callback',
|
||||
//'wrapper' => 'booking_variety_regn_feedback_wrapper',
|
||||
//'callback' => 'booking_variety_regn_callback',
|
||||
'wrapper' => 'booking_variety_session_wrapper',
|
||||
'callback' => 'booking_variety_session_callback',
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
// TODO: Update the whole form when booking ID is updated
|
||||
$form['variety-sessions'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Select Variety Sessions',
|
||||
'#prefix' => '<div id="booking_variety_session_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
//for each entry in the variety timeslot table, create a new form select item
|
||||
$timeslot_query = db_select('booking_variety_times', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
->fields('v')
|
||||
->orderBy('v.booking_variety_start');
|
||||
$result = $timeslot_query->execute();
|
||||
|
||||
foreach($result as $timeslot) {
|
||||
//create the form element for this timeslot
|
||||
$form['select-variety-' . $timeslot->tid] = array(
|
||||
$form['variety-sessions']['select-variety-' . $timeslot->tid] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => '',
|
||||
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
@@ -61,6 +71,41 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
);
|
||||
}
|
||||
|
||||
function booking_variety_session_callback($form, &$form_state) {
|
||||
global $event;
|
||||
//$node = $form_state['values']['form_id'];
|
||||
$data = $form_state['input'];
|
||||
watchdog('booking_debug', 'booking_variety_session_callback:<br /><pre>@info</pre>', array('@info' => print_r( $data, true)));
|
||||
$commands = array();
|
||||
|
||||
// Query the variety timeslot table
|
||||
$timeslot_query = db_select('booking_variety_times', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
->fields('v')
|
||||
->orderBy('v.booking_variety_start');
|
||||
$result = $timeslot_query->execute();
|
||||
|
||||
//for each entry in the variety timeslot table, create a new form select item
|
||||
foreach($result as $timeslot) {
|
||||
|
||||
$commands[] = ajax_command_replace('#select-variety-' . $timeslot->tid, drupal_render($form['variety-sessions']['select-variety-' . $timeslot->tid]));
|
||||
/*
|
||||
//create the form element for this timeslot
|
||||
$form['variety-sessions']['select-variety-' . $timeslot->tid] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => '',
|
||||
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to calculate available variety sessions for ajax enabled form booking_variety_regn_form()
|
||||
* @param $timeslot_id - the timeslot ID to query
|
||||
|
Reference in New Issue
Block a user