You are here

function _date_widget_settings in Date 5

Same name and namespace in other branches
  1. 5.2 date/date_admin.inc \_date_widget_settings()
  2. 6.2 date/date_admin.inc \_date_widget_settings()
  3. 6 date/date_admin.inc \_date_widget_settings()

Implementation of hook_widget_settings().

1 call to _date_widget_settings()
date_widget_settings in ./date.module

File

./date_admin.inc, line 33

Code

function _date_widget_settings($op, &$field) {
  switch ($op) {
    case 'callbacks':
      return array(
        'default value' => CONTENT_CALLBACK_CUSTOM,
      );
    case 'form':
      return date_widget_settings_form($field);
    case 'save':
      cache_clear_all('date_formats:' . $widget['field_name'] . ':' . $widget['type_name'], 'cache');
      return array(
        'default_value',
        'default_value_custom',
        'default_value2',
        'default_value_custom2',
        'input_format',
        'input_format_custom',
        'increment',
        'text_parts',
        'year_range',
      );
    case 'validate':
      if ($field['default_value'] == 'custom') {
        $is_strtotime = @strtotime($field['default_value_custom']);
        if (!$is_strtotime) {
          form_set_error('default_value_custom', t('The custom default value is invalid.'));
        }
      }
      if ($field['widget']['type'] == 'date_select' && !preg_match('@\\-[0-9]*:\\+[0-9]*@', $field['year_range'])) {
        form_set_error('year_range', t('Years back and forward must be in the format -9:+9.'));
      }

      // Munge the table display for text parts back into an array of text parts.
      if (is_array($field['text_parts'])) {
        form_set_value(array(
          '#parents' => array(
            'text_parts',
          ),
        ), array_keys(array_filter($field['text_parts'])));
      }
      break;
  }
}