You are here

function _datex_webform_date_element_validate in Datex 7.3

1 string reference to '_datex_webform_date_element_validate'
datex_webfrm_form_alter in datex_webfrm/datex_webfrm.module
Implements hook_form_alter().

File

datex_webfrm/datex_webfrm.module, line 27

Code

function _datex_webform_date_element_validate(&$el, &$fs, &$f) {
  $calendar = datex_factory();
  if (!$calendar) {
    return;
  }
  if ($el['month']['#value'] === '' || $el['day']['#value'] === '' || $el['year']['#value'] === '') {
    return;
  }
  foreach ([
    'day',
    'month',
    'year',
  ] as $field_type) {
    if (empty($el[$field_type]['#value'])) {
      return;
    }
  }
  $calendar
    ->setDateLocale($el['year']['#value'], $el['month']['#value'], $el['day']['#value']);
  $el['year']['#value'] = $calendar
    ->xFormat('Y');
  $el['month']['#value'] = $calendar
    ->xFormat('n');
  $el['day']['#value'] = $calendar
    ->xFormat('j');
}