Fix DateFormField readValue function
authorOlaf Braun <info@braun-development.de>
Wed, 15 Nov 2023 08:47:38 +0000 (09:47 +0100)
committerOlaf Braun <info@braun-development.de>
Wed, 15 Nov 2023 08:47:38 +0000 (09:47 +0100)
wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php

index 3256fc133327efcbbcbbf116343ca902bfc56961..06b4b2c235aa0ad4b12376caf70c6880add080e2 100644 (file)
@@ -291,10 +291,17 @@ class DateFormField extends AbstractFormField implements
             $this->getDocument()->hasRequestData($this->getPrefixedId())
             && \is_string($this->getDocument()->getRequestData($this->getPrefixedId()))
         ) {
-            $this->value = $this->getDocument()->getRequestData($this->getPrefixedId());
+            $value = $this->getDocument()->getRequestData($this->getPrefixedId());
+            $this->value = $value;
 
             if ($this->value === '') {
                 $this->value = null;
+            } elseif ($this->getValueDateTimeObject() === null) {
+                try {
+                    $this->value($value);
+                } catch (\InvalidArgumentException $e) {
+                    $this->value = null;
+                }
             }
         }