Fixed validation error with empty dates

This commit is contained in:
Manuel Cillero 2017-09-14 20:02:42 +02:00
parent 765af99d20
commit 0ea7ec6acf

View file

@ -2410,15 +2410,20 @@ function storm_dateext_validate($element, &$form_state) {
$format_match = str_replace('/', '\/', $format_match);
preg_match("/$format_match/", $element['#value']['popup']['date'], $matches);
$format = str_replace(array('/', '-'), '', $format);
$pos_d = max(strpos($format, 'd'), strpos($format, 'j')) + 1;
$pos_m = max(strpos($format, 'm'), strpos($format, 'M')) + 1;
$pos_y = strpos($format, 'Y') + 1;
if (empty($matches)) {
$element['#value'] = array('day' => -1, 'month' => -1, 'year' => -1);
}
else {
$format = str_replace(array('/', '-'), '', $format);
$pos_d = max(strpos($format, 'd'), strpos($format, 'j')) + 1;
$pos_m = max(strpos($format, 'm'), strpos($format, 'M')) + 1;
$pos_y = strpos($format, 'Y') + 1;
$element['#value'] = array();
$element['#value']['day'] = (int) $matches[$pos_d];
$element['#value']['month'] = (int) $matches[$pos_m];
$element['#value']['year'] = (int) $matches[$pos_y];
$element['#value'] = array();
$element['#value']['day'] = (int) $matches[$pos_d];
$element['#value']['month'] = (int) $matches[$pos_m];
$element['#value']['year'] = (int) $matches[$pos_y];
}
}
else {
if (!$element['#withnull'] && !empty($element['#value']['popup']['date'])) {