You are here

function _date_widget_settings in Date 6

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

Implementation of hook_widget_settings().

1 call to _date_widget_settings()
date_widget_settings in date/date.module
Wrapper functions for date administration, included only when processing field settings.

File

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

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':
      return array(
        'default_value',
        'default_value_code',
        'default_value2',
        'default_value_code2',
        'input_format',
        'input_format_custom',
        'increment',
        'text_parts',
        'year_range',
        'label_position',
      );
    case 'validate':
      if ($field['default_value'] == 'strtotime') {
        $is_strtotime = @strtotime($field['default_value_code']);
        if (!$is_strtotime) {
          form_set_error('default_value_code', t('The Strtotime default value is invalid.'));
        }
      }
      if ($field['default_value2'] == 'strtotime') {
        $is_strtotime = @strtotime($field['default_value_code2']);
        if (!$is_strtotime) {
          form_set_error('default_value_code2', t('The Strtotime default value for the To Date is invalid.'));
        }
      }
      if ($field['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.'));
      }
      break;
  }
}