1 form.inc html_datetime_validate($element, &$form_state)

Validate a combined date and time array.

Related topics

File

core/includes/form.inc, line 3386
Functions for form and batch generation and processing.

Code

function html_datetime_validate($element, &$form_state) {
  // Validation of parts actually happens in child fields.
  if (is_array($element['#value'])) {
    // If either is set, both are needed.
    if (!empty($element['#value']['date']) || !empty($element['#value']['time'])) {
      if (empty($element['#value']['date'])) {
        $element['#value']['date'] = format_date(REQUEST_TIME, DATE_FORMAT_DATE);
      }
      elseif (empty($element['#value']['time'])) {
        $element['#value']['time'] = '00:00:00';
      }
    }
  }
}