You are here

function bat_event_states_edit_event_form in Booking and Availability Management Tools for Drupal 7

Form to allow user to edit a single event.

1 string reference to 'bat_event_states_edit_event_form'
bat_event_menu in modules/bat_event/bat_event.module
Implements hook_menu().

File

modules/bat_event/bat_event.module, line 607
Manage Events - Events store the EventValue of a Unit over a period of time.

Code

function bat_event_states_edit_event_form($form, &$form_state, $event_id) {
  $state = db_select('bat_event_state', 'n')
    ->fields('n', array())
    ->condition('id', $event_id)
    ->execute()
    ->fetchAssoc();
  $form['state_id'] = array(
    '#type' => 'hidden',
    '#value' => $event_id,
  );
  $form['event_type'] = array(
    '#type' => 'hidden',
    '#value' => $state['event_type'],
  );
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('State Label'),
    '#default_value' => $state['label'],
    '#required' => TRUE,
  );
  $form['color'] = array(
    '#type' => 'textfield',
    '#title' => t('Color'),
    '#size' => 12,
    '#maxlength' => 7,
    '#default_value' => $state['color'],
    '#element_validate' => array(
      'bat_event_validate_hex_color',
    ),
    '#dependency' => array(
      'edit-row-options-colors-legend' => array(
        'type',
      ),
    ),
    '#prefix' => '<div class="bat-colorpicker-wrapper form-wrapper">',
    '#suffix' => '<div class="bat-colorpicker"></div></div>',
    '#attributes' => array(
      'class' => array(
        'bat-edit-colorpicker',
      ),
    ),
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      // Add javascript to trigger the colorpicker.
      'js' => array(
        drupal_get_path('module', 'bat_event') . '/js/bat_color.js',
      ),
    ),
    '#required' => TRUE,
  );
  $form['new_state']['calendar_label'] = array(
    '#type' => 'textfield',
    '#title' => t('Calendar label'),
    '#size' => 10,
    '#maxlength' => 50,
    '#default_value' => $state['calendar_label'],
    '#required' => TRUE,
  );
  $form['new_state']['blocking'] = array(
    '#type' => 'checkbox',
    '#title' => t('Blocking'),
    '#default_value' => $state['blocking'],
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update State'),
  );
  return $form;
}