ZF-3945: Zend_Form::addDefaultElementValidators() and similar
Description
I think it would make sense to add the option to Zend_Form to automatically add some filters/validators to elements created through it.
Example: - Create form - Set whitespace trimmer as the default form filter - Add elements "through" the form (addElement with text element name or createElement) with some filters of their own, i.e. an email field with an email validator - The default form element filters get prepended to the list of element-specific filters. For the email field, the value would first get trimmed and then validated as an email.
What do you think?
Comments
Posted by Jaka Jancar (jaka) on 2008-08-13T12:23:45.000+0000
Actually, in Zend_Form::createElement()'s docComment it says:
??Elements created with this method will not be attached to the form, but will contain element settings as specified in the form object (including plugin loader prefix paths, default decorators, etc.).??
Default decorators? I don't think that's being done at all?
Posted by Matthew Turland (elazar) on 2008-09-09T08:36:48.000+0000
I don't think that doc comment really makes sense. Adding the plugin loader prefix paths does, but forms and form elements don't use the same decorators. By that, I mean that each has decorators specific to itself; Zend_Form was designed to have its own decorators not decorators that it propagates to the form elements added to it.
I would like to see a way of configuring default decorators, filters, and validators to set for elements added to a form that didn't require subclassing Zend_Form, though. Perhaps this could be done by configuring and passing in a Zend_Form_Element instance?
Posted by Rob Allen (rob) on 2012-11-20T20:52:43.000+0000
Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".
Feel free to re-open and provide a patch if you want to fix this issue.