You are here

function date_field_settings_validate in Date 7

Same name and namespace in other branches
  1. 8 date_admin.inc \date_field_settings_validate()
  2. 5.2 date/date_admin.inc \date_field_settings_validate()
  3. 6.2 date/date_admin.inc \date_field_settings_validate()
  4. 6 date/date_admin.inc \date_field_settings_validate()
  5. 7.3 date.field.inc \date_field_settings_validate()
  6. 7.2 date.field.inc \date_field_settings_validate()

Custom field settings manipulation.

1 string reference to 'date_field_settings_validate'
_date_field_settings_form in ./date_admin.inc

File

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

Code

function date_field_settings_validate(&$form, &$form_state) {
  $field = $form_state['values']['field'];
  if ($field['settings']['tz_handling'] == 'none') {
    form_set_value($form['timezone_db'], '', $form_state);
  }
  else {
    form_set_value($form['timezone_db'], date_get_timezone_db($field['settings']['tz_handling']), $form_state);
  }
  if (!in_array('year', $field['settings']['granularity'])) {
    form_set_error('field][settings][granularity', t('Granularity must include a year.'));
  }
  if ($field['settings']['tz_handling'] != 'none' && !in_array('hour', array_filter($field['settings']['granularity']))) {
    form_set_error('field][settings][tz_handling', t('Dates without hours granularity must not use any timezone handling.'));
  }
}