ZF-4281: Various Issues with Zend_Form_Element_File
Zend_Form_Element_File delegates to the Zend_File_Transfer_Adapter all the validation effort.
The problem is while Zend_File_Transfer_Adapter have a validation process that mostly mimics validation in Zend_Form, the two processes remain different.
Here is what we lose compared to the validation offered by Zend_Form_Element:
- no support for the breakChainOnFailure feature. (this is a big one) - can't add custom messages unless you are instantiating the validators by hand and calling their setMessages method. (not convenient) - the syntax of the array passed to setValidators is different than the one of the other Zend_Form_Element(s). (breaks consistency which is never good)
I attached the file 'validation.php' that highlights the difference of syntax between Zend_Form_Element_File and the one of the other Zend_Form_Elememt(s).
Another issue with Zend_Form_Element_File: unlike other elements derived from Zend_Form_Element it doesn't seem to honor paths defined by a call to addElementPrefixPath on its parent form. Found that out when I tried to overload the 'Errors' decorator, Zend_Form_Element_File was the only element to still use the default one.
I also attached the Form_Element_File that I use for now to overcome all the problems above until they are fixed. It doesn't have all the bells and whistles of Zend_File_Transfer_Adapter but it does the job. (I don't recommend people using it since it hasn't been much tested but if someone does: don't forget to manually add the 'Upload' validator to the list of validators). Just like the original one, it won't work if used in a form where isArray is true or inside of a subform.
I hope that helps