Skip to content

Commit ccb2ed7

Browse files
committed
TFormNode::checkDependencies cannot be used because no child element (no added condition) returns false for this function either.
1 parent 23891fe commit ccb2ed7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

wcfsetup/install/files/lib/system/form/builder/container/condition/ConditionFormContainer.class.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,24 @@ public function validate()
4545
{
4646
parent::validate();
4747

48-
if ($this->isAvailable() && $this->checkDependencies()) {
48+
// `TFormNode::checkDependencies` also checks whether the container has at least one child element.
49+
// We only want to know whether the container is available; we will check later whether a child element is present.
50+
if ($this->isAvailable() && $this->checkDependency()) {
4951
$this->isEmpty = !$this->hasChildren();
5052
}
5153
}
5254

55+
private function checkDependency(): bool
56+
{
57+
foreach ($this->dependencies as $dependency) {
58+
if (!$dependency->checkDependency() || !$dependency->getField()->checkDependencies()) {
59+
return false;
60+
}
61+
}
62+
63+
return true;
64+
}
65+
5366

5467
public function hasValidationErrors(): bool
5568
{

0 commit comments

Comments
 (0)