function date_all_day_date_combo_pre_validate_alter in Date 8
Same name and namespace in other branches
- 7.3 date_all_day/date_all_day.module \date_all_day_date_combo_pre_validate_alter()
- 7.2 date_all_day/date_all_day.module \date_all_day_date_combo_pre_validate_alter()
Implements hook_date_combo_pre_validate_alter().
This hook lets us alter the element or the form_state before the rest of the date_combo validation gets fired.
File
- date_all_day/
date_all_day.module, line 303 - Adds All Day functionality to the Date field.
Code
function date_all_day_date_combo_pre_validate_alter(&$element, &$form_state, $context) {
if (!empty($context['item']['all_day'])) {
$field = $context['field'];
// If we have an all day flag on this date and the time is empty,
// change the format to match the input value so we don't get validation errors.
$element['#date_is_all_day'] = TRUE;
$element['value']['#date_date_format'] = date_part_format('date', $element['value']['#date_date_format']);
if (!empty($field['settings']['todate'])) {
$element['value2']['#date_date_format'] = date_part_format('date', $element['value2']['#date_date_format']);
}
}
}