Reputation: 6634
I am using Zend Framework and Doctrine on a project and was wondering if anyone can suggest a good way to integrate Doctrine's validation with Zend_Form. I'm trying to avoid code duplication.
Upvotes: 7
Views: 996
Reputation: 28716
If you are satisfied with aggregating the errors for your form you can do it in the following way: - Make a Zend_Form without validators - On submit, make a Doctrine object and call isValid() - If not valid, don't store, but show form again with an error
What I would recommend you however, is to either - Write both the validators for your Zend_Form and your model. - Write Validators for your Zend_Form that take a Doctrine Model and field as input and then validate the stuff against your model
I suppose the latter option could be a very generic library, useful for even inclusion into the Zend Framework. It is however tedious to write it in the right way.
Upvotes: 1