Reputation: 4048
I have form in ZF2 with input text and file fields. The fields has filters and validators. In text fields filters execute first, in file fields validators execute first. Why does it happen?
Upvotes: 1
Views: 106
Reputation: 32670
In ZF2, Filters
are in general applied before Validation
. Except, as you've mentionned, with the FileInput Filter
which is only applied if $form->getData()
is called.
The reason is that we need to make sure that the $_FILES
entry is valid before we do anything irrevocable (moving the file into a storage directory, renaming it,... etc). For this reason, file filters
need to be invoked after validation.
Upvotes: 4