Require label for `CheckboxFormField`
authorMatthias Schmidt <gravatronics@live.com>
Sun, 20 Dec 2020 10:05:19 +0000 (11:05 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 20 Dec 2020 10:05:19 +0000 (11:05 +0100)
wcfsetup/install/files/lib/system/form/builder/field/CheckboxFormField.class.php

index 7df2a5b09e20fcd7754b03cd2ef6856d13bd4b7d..495577b3f4c8771e63404cdcc55922fbd5d45524 100644 (file)
@@ -12,17 +12,16 @@ use wcf\system\WCF;
  * @since      5.3
  */
 class CheckboxFormField extends BooleanFormField {
-       /**
-        * @inheritDoc
-        */
-       protected $templateName = '__checkboxFormField';
-       
        /**
         * @inheritDoc
         */
        public function getHtml() {
+               if ($this->requiresLabel() && $this->getLabel() === null) {
+                       throw new \UnexpectedValueException("Form field '{$this->getPrefixedId()}' requires a label.");
+               }
+               
                return WCF::getTPL()->fetch(
-                       $this->templateName,
+                       '__checkboxFormField',
                        'wcf',
                        [
                                'field' => $this,