Then a form having the fieldset set as the base fieldset, a csrf, submit etc. and the input filter associated
And a validation group that has only the fieldset=>collection pair, something like
setValidationGroup([project => [
disciplines => [
id, name
]
]]);
if I submit the form with some elements in the collection
form->bind(object)
data = get POST
form->setData(data)
form->isValid()
are working as expected
when I submit the form with 0 elements in the collection, the POST is missing the project=>discipline array structure, it has only the form input(csrf and so on...)
if i feed this into the form, the validation fails, but not as I expect(by the way, the collection input filter has the is required flag set to true)
The returned error messages are for the entire fieldset inputs, like it does no take the validation group into account and the collection's isRequired flag.
The shortest workaround for me was to normalize the POST data and make sure that even if empty, the POST is following the correct array structure(like project=>[disciplines=>[//empty array...], csrf, submit], but it looks hackish.
This might be related to other issues that I found related to emptying the collection, but not sure if it was fixed, or this is the intended behavior...
Also can't follow the code completely, not sure if this is input filter related or form/fieldset related
I have the following classes defined
Let's call them: fieldset = project collection = disciplines
Then a form having the fieldset set as the base fieldset, a csrf, submit etc. and the input filter associated And a validation group that has only the fieldset=>collection pair, something like setValidationGroup([project => [ disciplines => [ id, name ] ]]);
if I submit the form with some elements in the collection form->bind(object) data = get POST form->setData(data) form->isValid() are working as expected
when I submit the form with 0 elements in the collection, the POST is missing the project=>discipline array structure, it has only the form input(csrf and so on...) if i feed this into the form, the validation fails, but not as I expect(by the way, the collection input filter has the is required flag set to true)
The returned error messages are for the entire fieldset inputs, like it does no take the validation group into account and the collection's isRequired flag.
The shortest workaround for me was to normalize the POST data and make sure that even if empty, the POST is following the correct array structure(like project=>[disciplines=>[//empty array...], csrf, submit], but it looks hackish.
This might be related to other issues that I found related to emptying the collection, but not sure if it was fixed, or this is the intended behavior... Also can't follow the code completely, not sure if this is input filter related or form/fieldset related