Abort field validation after first validation error
authorMatthias Schmidt <gravatronics@live.com>
Sun, 15 Apr 2018 14:25:23 +0000 (16:25 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 15 Apr 2018 14:25:23 +0000 (16:25 +0200)
See #2509

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

index b134dd8c510cf9b2a8f58d57aba29cea1acf41f8..9dcbb17fff78cd3e30b59486218f85ce2609787a 100644 (file)
@@ -239,8 +239,14 @@ abstract class AbstractFormField implements IFormField {
         * @inheritDoc
         */
        public function validate() {
-               foreach ($this->getValidators() as $validator) {
-                       $validator($this);
+               if (empty($this->getValidationErrors())) {
+                       foreach ($this->getValidators() as $validator) {
+                               $validator($this);
+                               
+                               if (!empty($this->getValidationErrors())) {
+                                       break;
+                               }
+                       }
                }
        }
 }