News Archive
PhpRiot Newsletter
Your Email Address:

More information

Lee Davis' Blog: FormFactory - Driving Doctrine 1.2 / 2.x Mappings into Zend_Form objects

Note: This article was originally published at PHPDeveloper on 31 March 2012.

Lee Davis has a recent post to his blog showing how you can combine the Zend_Form component of the Zend Framework with Doctrine to help directly "drive" your forms.

On a few of my previous projects I found myself creating more form classes than I'd like. And after the 30th one I figured there had to be a better way. I quickly realised that most of the elements within these forms shared similarities to the data type I would use on my database definitions. As I was using Doctrine at the time I figured I could not only drive my database from my mapping definitions, but my forms too.

He shows how his library (github) can be used to create a simple mapping between the form fields and the Doctrine entities, building from settings in an ini file. It also allows you to fall back to the normal Zend_Form configuration directives if you need something more custom. The post gets into more detail about using the project (configuring caching, other config options).

The project can be found here on github.