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:
foreach ($this->data as $key => $data) {
// ....
if (null !== $this->validationGroup) {
$inputFilter->setValidationGroup($this->validationGroup[$key]);
}
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:
$collection = new CollectionInputFilter(...);
$collection->setValidationGroup(array(
'a', 'b', 'c'
));
Now, for the first element in the list only property a is validated, property b 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:
$inputFilter->setValidationGroup($this->validationGroup);
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.