1 date.elements.inc | date_popup_element_value_callback($element, $input, &$form_state) |
Element value callback for date_popup element.
File
- core/
modules/ date/ date.elements.inc, line 939 - Date forms and form themes and validation.
Code
function date_popup_element_value_callback($element, $input, &$form_state) {
$granularity = date_format_order($element['#date_format']);
$has_time = date_has_time($granularity);
$date = NULL;
$return = $has_time ? array('date' => '', 'time' => '') : array('date' => '');
// Normal input from submitting the form element.
// Check is_array() to skip the string input values created by Views pagers.
// Those string values, if present, should be interpreted as empty input.
if ($input !== FALSE && is_array($input)) {
$return = $input;
$date = date_popup_input_date($element, $input);
}
// No input? Try the default value.
elseif (!empty($element['#default_value'])) {
$date = date_default_date($element);
}
// Date with errors won't re-display.
if (date_is_date($date)) {
$return['date'] = !$date->timeOnly ? date_format_date($date, 'custom', _date_popup_date_format($element)) : '';
$return['time'] = $has_time ? date_format_date($date, 'custom', _date_popup_time_format($element)) : '';
}
elseif (!empty($input)) {
$return = $input;
}
return $return;
}