I am currently working on a pretty large application which contains a lot of forms.
Up to this moment, I have always been writing my forms by hand and writing my own validation logic, but I have decided it was about time I started using Zend_Form and it's built-in validation routines.
However, I keep stumbling upon more and more problems concerning the (lack of) flexibility caused Zend_Form_Decorator
. Simple tasks like adding an extra button to a single input-element become incredibly difficult tasks.
I have now reached a point where I am seriously considering dropping the Zend_Form_Element
+ Zend_Form_Decorator
approach entirely, but I do not want to lose the excellent validation options.
Basically, I want the best of both worlds:
- Write forms the way the end-user sees them: in plain HTML
- Easily add server-side validations to form fields without breaking too much of the ZF standard behaviour
A possible solution I am considering is writing the forms both on the server side as in the views. This would allow me to easily validate my own forms, but the (in my eyes quite big) downside is that each form should be defined twice, which just feels plain wrong.
Are there any guidelines to do this? Have any of you experienced the same, and if so, how have you solved these issues?
I'd very much like to hear your points of view.