You are here

function date_field_instance_settings_form_validate in Date 7

Same name and namespace in other branches
  1. 8 date_admin.inc \date_field_instance_settings_form_validate()
  2. 7.3 date.field.inc \date_field_instance_settings_form_validate()
  3. 7.2 date.field.inc \date_field_instance_settings_form_validate()
1 string reference to 'date_field_instance_settings_form_validate'
_date_field_instance_settings_form in ./date_admin.inc

File

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

Code

function date_field_instance_settings_form_validate(&$form, &$form_state) {

  // The instance settings are in the wrong place in the form because of #tree on the top level.
  $settings = $form_state['values']['instance']['settings'];
  $settings = array_merge($settings, $settings['default']);
  unset($settings['default']);
  form_set_value(array(
    '#parents' => array(
      'instance',
      'settings',
    ),
  ), $settings, $form_state);
  if ($settings['default_value'] == 'strtotime') {
    $is_strtotime = @strtotime($settings['default_value_code']);
    if (!$is_strtotime) {
      form_set_error('instance][settings][default_value_code', t('The Strtotime default value is invalid.'));
    }
  }
  if (isset($settings['default_value2']) && $settings['default_value2'] == 'strtotime') {
    $is_strtotime = @strtotime($settings['default_value_code2']);
    if (!$is_strtotime) {
      form_set_error('instance][settings][default_value_code2', t('The Strtotime default value for the To Date is invalid.'));
    }
  }
}