Fix reading value of `CheckboxFormField`
authorMatthias Schmidt <gravatronics@live.com>
Wed, 7 Jul 2021 07:01:14 +0000 (09:01 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 7 Jul 2021 07:01:14 +0000 (09:01 +0200)
In contrast to `BooleanFormField` for which an explicit "no" input field exists, a normal checkbox does not submit any data if no checked.

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

index 495577b3f4c8771e63404cdcc55922fbd5d45524..41b6d67036221e41328be713617ac0d14dcfcdf6 100644 (file)
@@ -12,6 +12,15 @@ use wcf\system\WCF;
  * @since      5.3
  */
 class CheckboxFormField extends BooleanFormField {
+       /**
+        * @inheritDoc
+        */
+       public function readValue() {
+               $this->value = $this->getDocument()->hasRequestData($this->getPrefixedId());
+               
+               return $this;
+       }
+       
        /**
         * @inheritDoc
         */