function date_field_widget_settings_form_validate in Date 8
Same name and namespace in other branches
- 7.3 date.field.inc \date_field_widget_settings_form_validate()
- 7 date_admin.inc \date_field_widget_settings_form_validate()
- 7.2 date.field.inc \date_field_widget_settings_form_validate()
Form validation handler for _date_field_widget_settings_form().
3 string references to 'date_field_widget_settings_form_validate'
- DateFieldWidgetBase::settingsForm in date_field/
lib/ Drupal/ date_field/ Plugin/ field/ widget/ DateFieldWidgetBase.php - Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
- DateTextWidget::settingsForm in lib/
Drupal/ date/ Plugin/ field/ widget/ DateTextWidget.php - Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
- DateWidgetBase::settingsForm in lib/
Drupal/ date/ Plugin/ field/ widget/ DateWidgetBase.php - Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
File
- ./
date.module, line 613 - Defines date/time field types.
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['advanced']);
unset($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 ($widget['settings']['input_format'] === 'custom' && empty($widget['settings']['input_format_custom'])) {
form_set_error('instance][widget][settings][input_format_custom', t('Please enter a custom date format, or choose one of the preset formats.'));
}
switch ($widget['settings']['date_date_type']) {
case 'date':
$widget['settings']['date_date_format'] = variable_get('date_format_html_date', 'Y-m-d');
break;
}
switch ($widget['settings']['date_time_type']) {
case 'time':
$widget['settings']['date_times_format'] = variable_get('date_format_html_time', 'H:i:s');
break;
}
}