You are not logged in.
The goal would be to automagically have your application create Zend_Form elements based on a doctrine model definition, including fields for relationships, inheriting of validation rules defined in the doctrine model, customizing of the doctrine validation error messages and ignoring of fields that exist in the model but you do not necessarily want in the form.
The best start I found was this thread here http://www.nabble.com/Zend_Form-and-Doc … 32999.html I took that and modified it to allow for custom labels, decorators, element ordering and ignoring of fields...but it's definitely not the best solution. Has anyone else tried to do this or something similar?
Offline
hello ryan,
this is not really Zend_Form & doctrine related but I thought to mention it here...
I also started looking into Zend Framework & doctrine lately. Not doing very well btw... ![]()
I found this ressources pretty helpful:
This is the main article:
and this one refers to the previous article and offers a better implementation of the first part:
Some other good resources are:
Best, Udo
Offline
Thanks for the links, I read Matt's blog whenever I see an update ![]()
Offline
I think that tying forms directly to entities is kind of a bad idea. Having something that rapidly generates your whole form for you is great if you just want to re-create the functionality of phpMyAdmin, however when you're writing web apps, you usually don't want to present the user with more than 10 form fields at a time to being with. Also, by binding them directly, you don't easily allow yourself the opportunity to intercept requests without using dependency injection, event listeners and decorators.
It's by no means a bad move to leverage these patterns, but I think a direct bind between Zend_Form and Doctrine can cause headaches down the line in terms of maintainability. Writing a Zend_Form and then setting up an array at the top with the necessary form fields that you want and their type etc... should be enough to automatically have Zend_Form loop through and create the new form elements.
Also, you can just set parameters in Doctrine using dynamic property assignment. e.g.
// checks for validation should be outside this
$entity = new MyEntity();
foreach($this->getParams as $p=>$v)
$entity->$p = $v;
$entity->save();
Offline
I've been wanting to explore this concept a little more as well.
Its not so much that I want to be able to automatically generate the two (Zend_Form and Doctrine models) but just have them be "linked". I think the ultimate goal of what I am looking for is to have a single place where you define your schema and have all of the different aspects of the project reference those definitions.
Having your database be generated from the Doctrine schema.yml file is one step in having a single place to hold your schema information. However when you actually go about creating the user-facing interface (Zend_Form) you still have to (re)specify the different attributes (length, data-type, etc). Additionally if you write any client-side validation (javascript) you have to again (re)specify what you are validating.
So I think that the ultimate solution that I am looking for would require a single schema definition which would in turn create the database schema. Then you could link that definition back to a Zend_Form object which would also create client side (javascript) code as well. So, for example, if you wanted to change a field from string: 50 to string: 100, then it would only have to be changed in the single schema file and all of the other objects that reference it would be updated as well.
Thoughts? Are there currently any projects that are similar to what I am looking for?
Offline