You are here

function date_widget_settings_form in Date 5

Same name and namespace in other branches
  1. 5.2 date/date_admin.inc \date_widget_settings_form()
  2. 6.2 date/date_admin.inc \date_widget_settings_form()
  3. 6 date/date_admin.inc \date_widget_settings_form()
1 call to date_widget_settings_form()
_date_widget_settings in ./date_admin.inc
Implementation of hook_widget_settings().

File

./date_admin.inc, line 64

Code

function date_widget_settings_form($widget) {
  $form = array();

  // These settings are just placeholders. These values are not implemented until version 5.2
  // since it requires the PHP 5 code changes to make them work.
  $form['default_value'] = array(
    '#type' => 'hidden',
    '#value' => 'blank',
  );
  $form['default_value_custom'] = array(
    '#type' => 'hidden',
    '#value' => '',
  );
  $form['default_value2'] = array(
    '#type' => 'hidden',
    '#value' => 'blank',
  );
  $form['default_value_custom2'] = array(
    '#type' => 'hidden',
    '#value' => '',
  );
  $options = array();
  $formats = drupal_map_assoc(date_short_formats());
  $options['site-wide'] = t('Site default');
  foreach ($formats as $f) {
    $options[$f] = format_date(time(), 'custom', $f);
  }
  $form['input']['input_format'] = array(
    '#type' => 'select',
    '#title' => t('Input format'),
    '#default_value' => $widget['input_format'],
    '#options' => $options,
    '#description' => t('Set the order and format for the date parts in the input form. The format will be adapted to remove values not in the granularity for this field.'),
  );
  $form['input']['format']['input_format_custom'] = array(
    '#type' => 'textfield',
    '#title' => t('*Custom input format'),
    '#default_value' => $widget['input_format_custom'] ? $widget['input_format_custom'] : '',
    '#description' => t('The custom format, if provided, will override the input format selected above. See more about custom date formats below.'),
  );
  if ($widget['type'] == 'date_select') {
    $form['input']['advanced']['year_range'] = array(
      '#type' => 'textfield',
      '#title' => t('Years back and forward'),
      '#default_value' => isset($widget['year_range']) ? $widget['year_range'] : '-3:+3',
      '#size' => 10,
      '#maxsize' => 10,
      '#description' => t('Number of years to go back and forward when using a year selection list, default is -3:+3.'),
    );
    $form['input']['advanced']['increment'] = array(
      '#type' => 'select',
      '#title' => t('Time increment'),
      '#default_value' => isset($widget['increment']) ? $widget['increment'] : 1,
      '#options' => array(
        1 => 1,
        5 => 5,
        10 => 10,
        15 => 15,
        30 => 30,
      ),
      '#description' => t('Increment the minute and second fields by this amount.'),
    );
    $form['input']['advanced']['text_parts'] = array(
      '#tree' => TRUE,
      '#theme' => 'date_text_parts_theme',
    );
    $options = array(
      'year' => t('Year'),
      'mon' => t('Month'),
      'mday' => t('Day'),
    );
    foreach ($options as $key => $value) {
      $form['input']['advanced']['text_parts'][$key] = array(
        '#type' => 'radios',
        '#default_value' => in_array($key, (array) $widget['text_parts']) ? 1 : 0,
        '#options' => array(
          0 => '',
          1 => '',
        ),
      );
    }
  }
  return $form;
}