Fix validation of non-required user form field allowing multiple values
authorMatthias Schmidt <gravatronics@live.com>
Sat, 6 Apr 2019 10:19:35 +0000 (12:19 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 6 Apr 2019 10:19:35 +0000 (12:19 +0200)
See #2509

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

index fe086e60beca00ea0ce82166eb25a62ffa51a754..d52214a1ada3f583a9ba8bf2a74e98c84b67a93c 100644 (file)
@@ -63,7 +63,12 @@ class UserFormField extends AbstractFormField implements IAutoFocusFormField, II
         * @inheritDoc
         */
        public function validate() {
-               if ($this->isRequired() && ($this->getValue() === null || $this->getValue() === '') || (is_array($this->getValue()) && empty($this->getValue()))) {
+               if (
+                       $this->isRequired() && (
+                               ($this->getValue() === null || $this->getValue() === '') ||
+                               (is_array($this->getValue()) && empty($this->getValue()))
+                       )
+               ) {
                        $this->addValidationError(new FormFieldValidationError('empty'));
                }
                else if (!$this->isRequired()) {