From 38c2257c1e88f71ddc41243d72a905581bdcb252 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 26 Jan 2020 09:14:23 +0100 Subject: [PATCH] Fix validation of earliest and latest date in DateFormField --- .../system/form/builder/field/DateFormField.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php index 2e529a48d1..ca3ddb9cde 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php @@ -293,8 +293,10 @@ class DateFormField extends AbstractFormField implements IAutoFocusFormField, II 'format', 'wcf.form.field.date.error.format' )); + return; } - else if ($this->getEarliestDate() !== null) { + + if ($this->getEarliestDate() !== null) { $earliestDateTime = \DateTime::createFromFormat($this->getSaveValueFormat(), $this->getEarliestDate()); if ($dateTime < $earliestDateTime) { @@ -315,9 +317,11 @@ class DateFormField extends AbstractFormField implements IAutoFocusFormField, II 'wcf.form.field.date.error.earliestDate', ['earliestDate' => DateUtil::format($earliestDateTime, $format)] )); + return; } } - else if ($this->getLatestDate() !== null) { + + if ($this->getLatestDate() !== null) { $latestDateTime = \DateTime::createFromFormat($this->getSaveValueFormat(), $this->getLatestDate()); if ($dateTime > $latestDateTime) { @@ -336,8 +340,9 @@ class DateFormField extends AbstractFormField implements IAutoFocusFormField, II $this->addValidationError(new FormFieldValidationError( 'minimum', 'wcf.form.field.date.error.latestDate', - ['latestDateTime' => DateUtil::format($latestDateTime, $format)] + ['latestDate' => DateUtil::format($latestDateTime, $format)] )); + return; } } } -- 2.20.1