This is part 2 in a series on many to many with Zend_Form and Zend_Db. I suggest starting with last week’s video on Zend_Db and many-to-many in order to follow the configuration of our models. Grab the code and follow along! This concludes this series on Zend_Db. I’ve also uploaded a zipped version of the code if that’s easier than Google Code.
Many to Many with Zend_Form and Zend_Db
Description
This is part 2 in a series on many to many with Zend_Form and Zend_Db. I suggest starting with last week’s video on Zend_Db and many-to-many in order to follow the configuration of our models. Grab the code and follow along! This concludes this series on Zend_Db. I’ve also uploaded a zipped version of the…
Tags
Databases, forms, many-to-many, models, persistence, zend_controller

Thanks so much!
In recent casts is very much useful information.
I wish you success
Thank you very much about this cast
and for the zipped file
Thanks a lot for all your cast. I really appreciate what you do to make us a lot easier to learn ZF.
I find ZF very useful so I started to learn about it. My next project will be in ZF so every tip I can get is cool, and you gave me good tips
.
Thx
Nice cast, but I am waiting cast for modular setup. I dont get the modular way of working.
Hi Staar2,
Are you referring to Zend “Modules”?
I noticed you were using $dataRowset[0] to grab the first row in a Zend_Db_Table_Rowset.
Was there a reason you weren’t using ->current() or was it just convenient?
hey Derick… probably just convenience
Cool casts that that will give me a quick start
Anyway I think Zend is a cool thing, although the generated checkbox code is horrible…:
$this->addElement(new Zend_Form_Element_Checkbox(“test”));
generates
the dt/dd are so far ok, but what the hell should this hidden textfield? you normally have w3c compliant the possibility to have more checkboxes with the same name and get a comma separated list after post…
this is impossible with Zend because of this hidden field…
Cool casts that that will give me a quick start
Anyway I think Zend is a cool thing, although the generated checkbox code is horrible…:
$this->addElement(new Zend_Form_Element_Checkbox(“test”));
generates
>dt id=”test-label”>
>dd id=”test-element”>
>input type=”hidden” name=”test” value=”0″ />>input type=”checkbox” name=”test” id=”test” value=”1″ />>/dd>>/dl>
the dt/dd are so far ok, but what the hell should this hidden textfield? you normally have w3c compliant the possibility to have more checkboxes with the same name and get a comma separated list after post…
this is impossible with Zend because of this hidden field…
As far as I can tell, the hidden field is there so that you know whether the checkbox was checked or not. In a normal HTML form, a checkbox which hasn’t been checked isn’t included in the POST variables.
Extremely useful screen cast by the way.
Any ideas how you could include the “Associate” form into a “Create User” form? So that you can create a user and add task associations in one form?
Hi there, I think it would really be a better idea to use “Zend_Form_Element_Multiselect” to choose multiple tasks rather than checkboxes since multiselect provides an instant array and easier to handle.
Also, to get rid of unwanted form values to be saved, you can set ignore rather than delete it and recreate it after saving. This sounds a little bit inefficient.
There is a convenient function in Zend_Form to populate data from array, so simply follow a good naming convention in both database and Zend_Form would save you much work by using toArray in row class and populate all the data into the form for viewing.
Thank you. Your Video has been helpful a lot
Keep up the good work.