You are here

function _date_field_instance_settings_form in Date 7

Same name and namespace in other branches
  1. 8 date_admin.inc \_date_field_instance_settings_form()
  2. 7.3 date_admin.inc \_date_field_instance_settings_form()
  3. 7.2 date_admin.inc \_date_field_instance_settings_form()
1 call to _date_field_instance_settings_form()
date_field_instance_settings_form in ./date.field.inc
Wrapper functions for date administration, included only when processing field settings.

File

./date_admin.inc, line 159
Date administration code. Moved to separate file since there is a lot of code here that is not needed often.

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 value'),
    '#default_value' => $settings['default_value'],
    '#options' => array(
      'blank' => t('Blank'),
      'now' => t('Now'),
      'strtotime' => t('Relative'),
    ),
    '#description' => t("A default value to use for this field. If you select 'Relative', add details below."),
    '#weight' => 1,
  );
  if (!empty($field['settings']['todate'])) {
    $form['default_value2'] = array(
      '#type' => 'select',
      '#title' => t('Default value for To date'),
      '#default_value' => $settings['default_value2'],
      '#options' => array(
        'same' => t('Same as From date'),
        'blank' => t('Blank'),
        'now' => t('Now'),
        'strtotime' => t('Relative'),
      ),
      '#description' => t("A default value to use for this field. If you select 'Relative', add details below."),
      '#weight' => 2,
    );
  }
  $form['default'] = array(
    '#type' => 'fieldset',
    '#title' => t('Customize Default Value'),
    '#description' => '<p>' . t("The custom value for a Relative default should be something that describes a time by reference to the current day using strtotime, 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'),
    )) . '</p>',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 3,
  );
  $form['default']['default_value_code'] = array(
    '#type' => 'textfield',
    '#title' => t('Custom default value'),
    '#default_value' => $settings['default_value_code'],
  );
  if (!empty($field['settings']['todate'])) {
    $form['default']['default_value_code2'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom default value for To date'),
      '#default_value' => $settings['default_value_code2'],
    );
  }
  $format_types = array();
  foreach (_system_date_format_types_build() as $name => $info) {
    $format_types[$name] = $info['title'];
  }
  $form['default_format'] = array(
    '#type' => 'select',
    '#title' => t('Default Display'),
    '#default_value' => $settings['default_format'],
    '#options' => $format_types,
    '#description' => t('Select a default format type to be used for the date display. Visit the <a href="@date-time-page">Date and time date format page</a> to add and edit format types.', array(
      '@date-time-page' => url('admin/config/regional/date-time/formats'),
    )),
  );
  if (module_exists('date_repeat') && date_is_repeat_field($field, $instance)) {
    $form['repeat_collapsed'] = array(
      '#type' => 'radios',
      '#default_value' => $widget_settings['repeat_collapsed'],
      '#options' => array(
        0 => t('Expanded'),
        1 => t('Collapsed'),
      ),
      '#title' => t('Repeat display'),
      '#description' => t("Should the repeat options form start out expanded or collapsed? Set to 'Collapsed' to make those options less obtrusive."),
    );
  }
  $form['#element_validate'] = array(
    'date_field_instance_settings_form_validate',
  );
  return $form;
}