Validator::validateEqual returns always true if control value is empty array
woytam opened this issue · comments
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
where
foreach
evaluates each return value. But in case of $value
is empty array, foreach
never occurs.