function date_all_day_date_combo_pre_validate_alter in Date 7.2
Same name and namespace in other branches
- 8 date_all_day/date_all_day.module \date_all_day_date_combo_pre_validate_alter()
- 7.3 date_all_day/date_all_day.module \date_all_day_date_combo_pre_validate_alter()
Implements hook_date_combo_pre_validate_alter().
File
- date_all_day/
date_all_day.module, line 350 - Adds All Day functionality to the Date field.
Code
function date_all_day_date_combo_pre_validate_alter(&$element, &$form_state, $context) {
// This hook lets us alter the element or the form_state before the rest of
// the date_combo validation gets fired.
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_format'] = date_part_format('date', $element['value']['#date_format']);
if (!empty($field['settings']['todate'])) {
$element['value2']['#date_format'] = date_part_format('date', $element['value2']['#date_format']);
}
}
}