You are here

function availability_calendar_field_settings_form in Availability Calendars 7.3

Same name and namespace in other branches
  1. 7.5 availability_calendar.field.inc \availability_calendar_field_settings_form()
  2. 7.4 availability_calendar.field.inc \availability_calendar_field_settings_form()

Implements hook_field_settings_form(). @link http://api.drupal.org/api/drupal/modules--field_ui--field_ui.api.php/fun...

Availability Calendar field sets the allowed states and the default state at the field level.

File

./availability_calendar.field.inc, line 83
Availability Calendar module. Defines an availability calendar field.

Code

function availability_calendar_field_settings_form($field, $instance, $has_data) {
  module_load_include('inc', 'availability_calendar', 'availability_calendar.widget');
  $settings = $field['settings'];
  $form = array();
  $form['allocation_type'] = array(
    '#type' => 'radios',
    '#title' => t('Allocation type'),
    '#description' => t('Define the type of rental or allocation you want to support with this field. Differences are minor and are found in wording and rental period display.'),
    '#default_value' => $settings['allocation_type'],
    '#options' => array(
      ALLOCATION_TYPE_FULLDAY => t('Full day rental/allocation'),
      ALLOCATION_TYPE_OVERNIGHT => t('Overnight rental/allocation'),
    ),
  );
  $form['allowed_states'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Allowed states'),
    '#description' => t('Check the availability states that editors are allowed to select for this calendar instance.') . ' ' . t('Checking no states at all will allow all states.'),
    '#default_value' => $settings['allowed_states'],
    '#options' => availability_calendar_get_states('label'),
  );
  $form['default_state'] = array(
    '#type' => 'select',
    '#title' => t('Default state'),
    '#default_value' => $settings['default_state'],
    '#required' => TRUE,
    '#options' => availability_calendar_get_states('label'),
    '#description' => t('Define the state for days that not yet have a state set. This does not have to be an allowed state.'),
  );
  return $form;
}