function bat_event_unit_set_state_form in Booking and Availability Management Tools for Drupal 7
Configuration form for the VBO action: Assign fixed-state event to units.
File
- modules/
bat_event/ bat_event.module, line 2614 - Manage Events - Events store the EventValue of a Unit over a period of time.
Code
function bat_event_unit_set_state_form($context, &$form_state) {
$form = array();
$event_types_options = array();
$event_types = bat_event_get_types();
foreach ($event_types as $event_type) {
if ($event_type->fixed_event_states) {
$event_types_options[$event_type->type] = $event_type->label;
}
}
$form += bat_date_range_fields();
$form['event_type'] = array(
'#type' => 'select',
'#title' => t('Event type'),
'#options' => $event_types_options,
'#required' => TRUE,
'#ajax' => array(
'callback' => 'bat_event_unit_set_state_form_callback',
'wrapper' => 'event-state-wrapper',
),
);
if (isset($form_state['values']['event_type'])) {
$state_options = array();
foreach (bat_event_get_states($form_state['values']['event_type']) as $state) {
$state_options[$state['machine_name']] = $state['label'];
}
$form['event_state'] = array(
'#type' => 'select',
'#title' => t('Event state'),
'#options' => $state_options,
'#required' => TRUE,
'#prefix' => '<div id="event-state-wrapper">',
'#suffix' => '</div>',
);
}
else {
$form['event_state'] = array(
'#prefix' => '<div id="event-state-wrapper">',
'#suffix' => '</div>',
);
}
return $form;
}