Fix validation of earliest and latest date in DateFormField
authorMatthias Schmidt <gravatronics@live.com>
Sun, 26 Jan 2020 08:14:23 +0000 (09:14 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 26 Jan 2020 08:14:23 +0000 (09:14 +0100)
wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php

index 2e529a48d1d528d86550365f735154ca39e861d9..ca3ddb9cdeedc956ede52213f19a147b95b9310f 100644 (file)
@@ -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;
                                }
                        }
                }