Form field dependencies now have to be fulfilled all at once
authorMatthias Schmidt <gravatronics@live.com>
Sat, 30 Jun 2018 07:49:29 +0000 (09:49 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 30 Jun 2018 07:49:29 +0000 (09:49 +0200)
See #2509

wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager.js
wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php

index 1b830d196c84c3ffcd3216f73c7e0d6f25c88312..bdb92d1447e619db3f53684873be6bdddafc24c0 100644 (file)
@@ -181,15 +181,15 @@ define(['Dictionary', 'Dom/ChangeListener', 'EventHandler', 'List', 'Dom/Travers
                                }
                                
                                for (var i = 0, length = nodeDependencies.length; i < length; i++) {
-                                       // if any dependency is met, the element is visible
-                                       if (nodeDependencies[i].checkDependency()) {
-                                               this._show(dependentNode);
+                                       // if any dependency is not met, hide the element
+                                       if (!nodeDependencies[i].checkDependency()) {
+                                               this._hide(dependentNode);
                                                return;
                                        }
                                }
                                
-                               // no node dependency is met
-                               this._hide(dependentNode);
+                               // all node dependency is met
+                               this._show(dependentNode);
                        }.bind(this));
                        
                        // delete dependencies for removed elements
index cc82f0d5a5b5ada651c9f3102db5655427c68475..c607ee8b929602bb63898a0cadf314e072786819 100644 (file)
@@ -148,16 +148,11 @@ trait TFormNode {
         */
        public function checkDependencies(): bool {
                if (!empty($this->dependencies)) {
-                       $hasMetDependency = false;
                        foreach ($this->dependencies as $dependency) {
-                               if ($dependency->checkDependency()) {
-                                       $hasMetDependency = true;
+                               if (!$dependency->checkDependency()) {
+                                       return false;
                                }
                        }
-                       
-                       if (!$hasMetDependency) {
-                               return false;
-                       }
                }
                
                if ($this instanceof IFormParentNode) {