Add missing value validation in `TSelectionFormField`
authorMatthias Schmidt <gravatronics@live.com>
Sat, 19 May 2018 07:42:55 +0000 (09:42 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 19 May 2018 07:42:55 +0000 (09:42 +0200)
See #2509

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

index 3487cdbbb8ba97946bb5a4c1f4490cdae4ba578f..24d13501cd83d09b93aae7b64353df2adb0cecab 100644 (file)
@@ -149,4 +149,15 @@ trait TSelectionFormField {
                
                parent::validate();
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function value($value): IFormField {
+               if (!in_array($value, $this->possibleValues)) {
+                       throw new \InvalidArgumentException("Unknown value '{$value}'");
+               }
+               
+               return parent::value($value);
+       }
 }