You are here

function date_text_element_value_callback in Date 7.2

Same name and namespace in other branches
  1. 7.3 date_api/date_api_elements.inc \date_text_element_value_callback()
  2. 7 date_api/date_api_elements.inc \date_text_element_value_callback()

Element value callback for date_text element.

1 string reference to 'date_text_element_value_callback'
_date_api_element_info in date_api/date_api_elements.inc
Wrapper for hook_element_info().

File

date_api/date_api_elements.inc, line 293
Date API elements themes and validation.

Code

function date_text_element_value_callback($element, $input = FALSE, &$form_state = array()) {
  $return = array(
    'date' => '',
  );
  $date = NULL;

  // 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) && !is_null($input['date'])) {
    $return = $input;
    $date = date_text_input_date($element, $input);
  }
  elseif (!empty($element['#default_value'])) {
    $date = date_default_date($element);
  }
  if (date_is_date($date)) {
    $return['date'] = date_format_date($date, 'custom', $element['#date_format']);
  }
  return $return;
}