Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine and Zend_Form Validation

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.

like image 538
rr. Avatar asked Oct 23 '09 20:10

rr.


1 Answers

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.

like image 197
Peter Smit Avatar answered Sep 18 '22 17:09

Peter Smit