You are here

function _datex_select_date_field_element_validate_callback in Datex 7.3

To convert the day back to Gregorian.

1 string reference to '_datex_select_date_field_element_validate_callback'
datex_element_info_alter in ./datex_date.inc
Adds datex as a date form element validator.

File

./datex_date.inc, line 183
Provides support for date module.

Code

function _datex_select_date_field_element_validate_callback(&$element, &$fs) {
  $calendar = _datex_date_field_calendar($element, FALSE, 'en');
  if (!$calendar) {
    return;
  }
  $is_view = isset($fs['view']);
  $fval = _datex_get_fs($element, $fs);
  $err = $calendar
    ->validate($fval);
  if ($err === NULL) {
    return;
  }
  if ($err !== FALSE) {
    form_set_error(implode('][', $element['#parents']), check_plain($err));
  }
  if ($fval) {
    $calendar
      ->setDateLocale($fval['year'], isset($fval['month']) ? $fval['month'] : 6, isset($fval['day']) ? $fval['day'] : 22);

    // Drupal 8 default time.
    $calendar
      ->setTime(isset($fval['hour']) ? $fval['hour'] : 12, isset($fval['minute']) ? $fval['minute'] : 0, isset($fval['second']) ? $fval['second'] : 0);
    $f = $calendar
      ->xFormatArray();
    _datex_set_fs($element, $fs, $f, NULL, TRUE);
    _datex_set_fs($element, $fs, $f, NULL, FALSE);
  }
}