-
-
Notifications
You must be signed in to change notification settings - Fork 151
Closed
Milestone
Description
Version: master branch
Bug Description
When using addConditionOn() with MultichoiceControl and the value ($multichoicecontrol->getValue()) is empty array [], condition is always true.
Steps To Reproduce
$form->addCheckboxList('multi', 'Label', ['key' => ''])
->setValue([]);
$form->addText('textName')
->addConditionOn($form['multi'], $form::EQUAL, ['key'])
->setRequired();
textName is always required.
Expected Behavior
textName required only if key from checkboxList is selected.
Possible Solution
The problem is in validator.php, where if control value ($value = $checkboxList->getValue()) returns empty array, it is considered as equal.
I have found problematic code in
Line 104 in a472e9e
| foreach ((is_array($value) ? $value : [$value]) as $val) { |
where
foreach evaluates each return value. But in case of $value is empty array, foreach never occurs.Metadata
Metadata
Assignees
Labels
No labels