You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
While debugging a problem when validating a complex form containing collections and validation groups to limit the fields that are being validated I notice the following code in CollectionInputFilter:
If the CollectionInputFilter has a validation group then the validation group is indexed using the same key as the data. A validation group is assigned like this:
I can work around this by calling $collection->getInputFilter()->setValidationGroup(...) instead, however this prevents me of performing a single setValidationGroup call at the root of my form with a single nested array for the entire form.
The text was updated successfully, but these errors were encountered:
$inputFilter = newInputFilter();
$inputFilter->add([
'name' => 'foo',
'required' => true,
]);
$inputFilter->add([
'name' => 'bar',
'required' => true,
]);
$collection = newCollectionInputFilter();
$collection->setInputFilter($inputFilter);
$collection->setValidationGroup([0 => ['bar'], 1 => ['foo']]);
$collection->setData([
0 => ['bar' => 'value'], // valid because only 'bar' in validation group1 => ['foo' => 'value2'] // valid because only 'foo' in validation group
]);
$collection->isValid();
Okay I am not sure this is desired behavior nor use case for this, but well can't think otherwise why setValidationGroup() is called in every foreach loop. And also there is a test for this so can't be fixed?
also data being array of 3 elements will throw Undefined offset: 2
@weierophinney what do you think? If this is a bug I can create PR with a fix.
While debugging a problem when validating a complex form containing collections and validation groups to limit the fields that are being validated I notice the following code in
CollectionInputFilter
:If the
CollectionInputFilter
has a validation group then the validation group is indexed using the same key as the data. A validation group is assigned like this:Now, for the first element in the list only property
a
is validated, propertyb
for the second, etc.Am I missing something in the way I assign my validation group? Or should the line where the validation group is assigned read:
I can work around this by calling
$collection->getInputFilter()->setValidationGroup(...)
instead, however this prevents me of performing a singlesetValidationGroup
call at the root of my form with a single nested array for the entire form.The text was updated successfully, but these errors were encountered: