Optional select fields were not optional because of a property mismatch
authorAlexander Ebert <ebert@woltlab.com>
Tue, 21 Jan 2020 16:49:42 +0000 (17:49 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 21 Jan 2020 16:49:42 +0000 (17:49 +0100)
wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php

index dbed4ac1b90e5f50cc9ae873264c64fd9f41aef8..851e0af31932e775ff4ff0211b6baffca920d6d9 100644 (file)
@@ -39,6 +39,19 @@ abstract class CustomOption extends Option implements ITitledObject {
         */
        protected $optionValue = '';
        
+       /**
+        * @inheritDoc
+        */
+       public function __get($name) {
+               // Some options support empty values, such as "select", but the code checks for the
+               // property `allowEmptyValue`, which is the inverse value of `required`.
+               if ($name === 'allowEmptyValue') {
+                       return !$this->required;
+               }
+               
+               return parent::__get($name);
+       }
+       
        /**
         * @inheritDoc
         * @since       5.2