You are here

function date_field_widget_info in Date 7

Same name and namespace in other branches
  1. 7.3 date.field.inc \date_field_widget_info()
  2. 7.2 date.field.inc \date_field_widget_info()

Implements hook_field_widget_info().

1 call to date_field_widget_info()
date_tools_wizard_widget_types in date_tools/date_tools.wizard.inc

File

./date.field.inc, line 220
Field hooks to implement a date field.

Code

function date_field_widget_info() {
  $settings = array(
    'settings' => array(
      'input_format' => date_default_format('date_select'),
      'input_format_custom' => '',
      'increment' => 1,
      'text_parts' => array(),
      'year_range' => '-3:+3',
      'label_position' => 'above',
      'repeat_collapsed' => 0,
    ),
    'behaviors' => array(
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
      'default value' => FIELD_BEHAVIOR_CUSTOM,
    ),
  );

  // Repeating dates have custom handling
  // for multiple values.
  $repeat_settings = $settings;
  $repeat_settings['behaviors']['multiple values'] = FIELD_BEHAVIOR_CUSTOM;
  $info = array(
    'date_select' => array(
      'label' => t('Select List'),
      'field types' => array(
        'date',
        'datestamp',
        'datetime',
      ),
    ) + $settings,
    'date_select_repeat' => array(
      'label' => t('Select List with Repeat options'),
      'field types' => array(
        'date',
        'datestamp',
        'datetime',
      ),
    ) + $repeat_settings,
    'date_text' => array(
      'label' => t('Text Field with custom input format'),
      'field types' => array(
        'date',
        'datestamp',
        'datetime',
      ),
    ) + $settings,
    'date_text_repeat' => array(
      'label' => t('Text Field with Repeat options'),
      'field types' => array(
        'date',
        'datestamp',
        'datetime',
      ),
    ) + $repeat_settings,
  );
  if (module_exists('date_popup')) {
    $info['date_popup'] = array(
      'label' => t('Text Field with Date Pop-up calendar'),
      'field types' => array(
        'date',
        'datestamp',
        'datetime',
      ),
    ) + $settings;
    $info['date_popup_repeat'] = array(
      'label' => t('Text Field with Date Pop-up and Repeat options'),
      'field types' => array(
        'date',
        'datestamp',
        'datetime',
      ),
    ) + $repeat_settings;
  }
  if (!module_exists('date_repeat')) {
    unset($info['date_select_repeat']);
    unset($info['date_text_repeat']);
    if (isset($info['date_popup_repeat'])) {
      unset($info['date_popup_repeat']);
    }
  }
  return $info;
}