Due to popular demand, I have now pushed both packageizer and ZF modelform to GitHub. Feel free to fork them or do whatever :)
ModelForm developments
I’ve been reworking the ModelForm class for ZF a bit. Earlier this year, I discussed porting it to use Zend_Db_Table with Matthew Weier O’Phinney, for using it with Zend Framework. I initially had done some checking on Zend_Db_Table, and some small code changes to modify the class to use it instead of Doctrine, but I ran into some issues. Now, I’ve had some time to think about it, I’ve reworked the class slightly and added basic Zend_Db_Table support, too…
Doctrine 2 adapter for Zend_Form model form generator
I recently updated the ZF modelform generator to include an adapter compatible with Doctrine 2.
It’s otherwise completely functional, but it ignores many-to-many relations when generating forms (because I didn’t need this feature yet ;) ).
Usage example after the jump.
Another idea for using models with forms
Matthew Weier O’Phinney wrote about using Zend_Form with models. His approach puts a form inside a model, which then uses the form to validate itself.
While this idea is not bad, I find it being upside down – I think the form should use the model to validate itself, not the other way around.
But how would you utilize a model class to validate a form? I think there are two feasible ways to do so: A global model for a form, and a model-based validator class…
The problems faced by a common model interface in frameworks
You sometimes see people asking why the Zend Framework (or some others) don’t provide a library for the Model part in MVC.
While ZF provides data access classes in the form of Zend_Db and related components, it doesn’t provide any concrete examples of how you would implement a model class. This often confuses especially beginners.
Providing a common base model, or an interface for implementing models, does have certain benefits, but it also has some problems…
Zend_Form’s from Doctrine models: Part 2
Previously I wrote about my class for generating Zend_Form forms from Doctrine models. This time, let’s look at some more usage examples and how it works internally, to make it easier for you to utilize it.
Edit 10.10.2008: Updated the post to reflect some minor changes in the CU_ModelForm class
Autogenerating forms from Doctrine models
In a previous post I mentioned how Django’s model forms are awesome.
I really like the idea of being able to generate forms automatically from models – I mean the models already should contain most of the data you’d need: the fields, field types and how they will be stored.
Since I was already quite familiar with Doctrine’s internals, I knew it would be possible to find out all the data on the models quite easily, and set upon creating a class which generates Zend Framework’s Zend_Form based form classes from Doctrine models…
Edit 10.10.2008: Updated the post to reflect some minor changes in the CU_ModelForm class