You are here

function date_text_element_value_callback in Date 7

Same name and namespace in other branches
  1. 7.3 date_api/date_api_elements.inc \date_text_element_value_callback()
  2. 7.2 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
Implementation of hook_element_info().

File

date_api/date_api_elements.inc, line 188
Date API elements themes and validation. This file is only included during the edit process to reduce memory usage.

Code

function date_text_element_value_callback($element, $input = FALSE, &$form_state) {
  $return = array(
    'date' => '',
  );
  $date = NULL;
  if ($input !== FALSE) {
    $return = $input;
    $date = date_text_input_date($element, $input);
  }
  elseif (!empty($element['#default_value'])) {
    $date = date_default_date($element);
  }
  if (is_object($date) && empty($date->errors)) {
    $return['date'] = $date
      ->format($element['#date_format']);
  }
  return $return;
}