You are here

function date_field_settings_form in Date 5

Same name and namespace in other branches
  1. 8 date.field.inc \date_field_settings_form()
  2. 5.2 date/date_admin.inc \date_field_settings_form()
  3. 6.2 date/date_admin.inc \date_field_settings_form()
  4. 6 date/date_admin.inc \date_field_settings_form()
  5. 7.3 date.field.inc \date_field_settings_form()
  6. 7 date.field.inc \date_field_settings_form()
  7. 7.2 date.field.inc \date_field_settings_form()
1 call to date_field_settings_form()
_date_field_settings in ./date_admin.inc
Implementation of hook_field_settings().

File

./date_admin.inc, line 233

Code

function date_field_settings_form($field) {
  $form = array();
  $tz_handling = $field['tz_handling'] ? $field['tz_handling'] : (date_has_time($field['granularity']) ? 'site' : 'none');
  $form['input']['todate'] = array(
    '#type' => 'select',
    '#title' => t('To Date'),
    '#options' => array(
      '' => t('Never'),
      'optional' => t('Optional'),
      'required' => t('Required'),
    ),
    '#description' => t("Display a matching second date field as a 'To date'. If marked 'Optional' field will be presented but not required. If marked 'Required' the 'To date' will be required if the 'From date' is required or filled in."),
    '#default_value' => $field['todate'] ? $field['todate'] : '',
  );
  $form['input']['granularity'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Granularity'),
    '#default_value' => $field['granularity'] ? $field['granularity'] : array(
      'Y',
      'M',
      'D',
      'H',
      'N',
    ),
    '#options' => date_granularity_names(),
    '#multiple' => TRUE,
    '#size' => min(count($options), 6),
    '#description' => t('Set the date elements to be stored (at least a year is required).'),
  );
  $form['output']['simple'] = date_formatter_setup_form($field, 0);
  $form['output']['simple']['#title'] = t('Default Display');
  $form['output']['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Additional Display Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('Define alternate formatting for the date display. Options other than the default are made available to views and themes. Possible formats are default, long, medium, and short.'),
  );
  for ($i = 1; $i <= 3; $i++) {
    $form['output']['advanced'][$i] = date_formatter_setup_form($field, $i);
  }
  $form['timezone']['tz_handling'] = array(
    '#type' => 'select',
    '#title' => t('Time zone handling'),
    '#default_value' => $tz_handling,
    '#options' => date_timezone_handling_options(),
    '#description' => t('Select the timezone handling method to be used for this date field.'),
  );

  // Force this value to hidden because we don't want to allow it to be changed right now,
  // but allow it to be a variable if needed.
  $form['timezone']['timezone_db'] = array(
    '#type' => 'hidden',
    '#value' => 'UTC',
  );

  // need a way to identify the correct system timezone from an array of timezones with the same offset
  // save it as a system variable so it will default to the correct value after the first time it is set
  // aligns with system setting 'date_default_timezone'
  $form['timezone']['advanced']['field_timezone'] = array(
    '#type' => 'select',
    '#title' => t('Site timezone'),
    '#default_value' => date_get_site_timezone(),
    '#options' => drupal_map_assoc(date_timezone_options()),
    '#description' => t('Select the timezone to be used as the site\'s timezone for all date fields in every content type in which they appear. List includes GMT and all timezones with the same GMT offset as the site timezone setting.'),
  );
  $form['#suffix'] = t('<div class="form-item"><div class="description">* The custom format, if provided, will override the selected display or input options. Define a php date format string like \'m-d-Y H:i\' (see !link for more details).</div></div>', array(
    '!link' => l('http://php.net/date', 'http://php.net/date'),
  ));
  return $form;
}