Ignore `null` as passed value for `TSelectionFormField::value()`
authorMatthias Schmidt <gravatronics@live.com>
Mon, 28 May 2018 18:13:31 +0000 (20:13 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 28 May 2018 18:13:31 +0000 (20:13 +0200)
See #2509

wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php

index 24d13501cd83d09b93aae7b64353df2adb0cecab..fdb25a800c505395f347f011a0b795ef6bb858b7 100644 (file)
@@ -154,6 +154,12 @@ trait TSelectionFormField {
         * @inheritDoc
         */
        public function value($value): IFormField {
+               // ignore `null` as value which can be passed either for nullable
+               // fields or as value if no options are available
+               if ($value === null) {
+                       return $this;
+               }
+               
                if (!in_array($value, $this->possibleValues)) {
                        throw new \InvalidArgumentException("Unknown value '{$value}'");
                }