You are here

function _date_field_instance_settings_form in Date 8

Same name and namespace in other branches
  1. 7.3 date_admin.inc \_date_field_instance_settings_form()
  2. 7 date_admin.inc \_date_field_instance_settings_form()
  3. 7.2 date_admin.inc \_date_field_instance_settings_form()

Helper function for date_field_instance_settings_form().

See also

date_field_instance_settings_form_validate()

1 call to _date_field_instance_settings_form()
date_field_instance_settings_form in ./date.field.inc
Implements hook_field_instance_settings_form().

File

./date_admin.inc, line 15
Date administration code.

Code

function _date_field_instance_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $instance['settings'];
  $widget_settings = $instance['widget']['settings'];
  $form['default_value'] = array(
    '#type' => 'select',
    '#title' => t('Default date'),
    '#default_value' => $settings['default_value'],
    '#options' => array(
      'blank' => t('No default value'),
      'now' => t('Now'),
      'strtotime' => t('Relative'),
    ),
    '#weight' => 1,
    '#fieldset' => 'default_values',
  );
  $description = t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See !strtotime for more details.", array(
    '!strtotime' => l(t('strtotime'), 'http://www.php.net/manual/en/function.strtotime.php'),
  ));
  $form['default_value_code'] = array(
    '#type' => 'textfield',
    '#title' => t('Relative default value'),
    '#description' => $description,
    '#default_value' => $settings['default_value_code'],
    '#states' => array(
      'visible' => array(
        ':input[name="instance[settings][default_value]"]' => array(
          'value' => 'strtotime',
        ),
      ),
    ),
    '#weight' => 1.1,
    '#fieldset' => 'default_values',
  );
  $form['default_value2'] = array(
    '#type' => !empty($field['settings']['todate']) ? 'select' : 'hidden',
    '#title' => t('Default end date'),
    '#default_value' => $settings['default_value2'],
    '#options' => array(
      'same' => t('Same as Default date'),
      'blank' => t('No default value'),
      'now' => t('Now'),
      'strtotime' => t('Relative'),
    ),
    '#weight' => 2,
    '#fieldset' => 'default_values',
  );
  $form['default_value_code2'] = array(
    '#type' => !empty($field['settings']['todate']) ? 'textfield' : 'hidden',
    '#title' => t('Relative default value for end date'),
    '#description' => $description,
    '#default_value' => $settings['default_value_code2'],
    '#states' => array(
      'visible' => array(
        ':input[name="instance[settings][default_value2]"]' => array(
          'value' => 'strtotime',
        ),
      ),
    ),
    '#weight' => 2.1,
    '#fieldset' => 'default_values',
  );
  $form['all_day_toggle'] = array(
    '#type' => 'select',
    '#title' => t('All day toggle'),
    '#description' => t("Add an 'All day' checkbox to the form to allow the user to hide or show the time."),
    '#default_value' => $settings['all_day_toggle'],
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#weight' => 2,
  );
  $form['#element_validate'] = array(
    'date_field_instance_settings_form_validate',
  );
  $context = array(
    'field' => $field,
    'instance' => $instance,
  );
  drupal_alter('date_field_instance_settings_form', $form, $context);
  return $form;
}