function date_field_widget_settings_form_validate in Date 7
Same name and namespace in other branches
- 8 date.module \date_field_widget_settings_form_validate()
- 7.3 date.field.inc \date_field_widget_settings_form_validate()
- 7.2 date.field.inc \date_field_widget_settings_form_validate()
1 string reference to 'date_field_widget_settings_form_validate'
File
- ./
date_admin.inc, line 371 - Date administration code. Moved to separate file since there is a lot of code here that is not needed often.
Code
function date_field_widget_settings_form_validate(&$form, &$form_state) {
// The widget settings are in the wrong place in the form because of #tree on the top level.
$settings = $form_state['values']['instance']['widget']['settings'];
$settings = array_merge($settings, $settings['format'], $settings['advanced']);
unset($settings['format'], $settings['advanced']);
form_set_value(array(
'#parents' => array(
'instance',
'widget',
'settings',
),
), $settings, $form_state);
$widget = $form_state['values']['instance']['widget'];
// Munge the table display for text parts back into an array of text parts.
if (is_array($widget['settings']['text_parts'])) {
form_set_value($form['text_parts'], array_keys(array_filter($widget['settings']['text_parts'])), $form_state);
}
if (in_array($widget['type'], array(
'date_select',
'date_popup',
'date_select_repeat',
'date_popup_repeat',
)) && !date_range_valid($widget['settings']['year_range'])) {
form_set_error('instance][widget][settings][year_range', t('Years back and forward must be in the format -9:+9.'));
}
}