function _datex_popup_element_validate_callback in Datex 7.2
Form element validation callback.
Converts a Jalali date to Gregorian date just before actual validation of date element happens.
1 call to _datex_popup_element_validate_callback()
- _datex_element_validate_callback in ./
datex_date.inc - Form element validation callback.
File
- datex_popup/
datex_popup.module, line 163
Code
function _datex_popup_element_validate_callback(&$element, &$form_state) {
// If there are already error on form let them be fixed first.
if (empty($element['date']['#value']) || form_get_errors()) {
return;
}
list($schema, $g) = _datex_popup_get_element_info($element);
$tz = $element['#date_timezone'];
if (!($calendar = _datex_field_calendar($g, $schema, $tz))) {
return;
}
$datex = $element['datex_' . str_replace('-', '_', $element['#id'])];
$values = explode('-', $datex['#value']);
if (count($values) == 3) {
$calendar
->setDate($values[0], $values[1], $values[2]);
$format = date_limit_format($element['#date_format'], date_popup_date_granularity($element));
$element['date']['#value'] = $calendar
->xformat(_datex_popup_php_format($format));
}
form_set_value($element['date'], $element['date']['#value'], $form_state);
_datex_form_set_input($element['date'], $element['date']['#value'], $form_state);
}