0
votes

How I can create for with one to many relations? For example I have an Object and him have relations to many images? I usually use symfony and it have form collection type. Maybe Zend have something like that?

UPDATE:
I want create this form using Zend_Form.

1
Can you clarify your question? Are you referring to forms or database tables with a one to many relation? - Luke
@Luke I want create this form using Zend_Form. - rtyshyk
I'm still not sure what you are asking. Can you give an example? If you have an object with a property set to an array, you can use a foreach loop to go through the array and dynamically add form elements inside the loop. Not sure if this answers your question though. Are you asking how to get the array from the database, or how to populate the form? - Luke
I'm not sure, but sub forms may be what you are looking for. - vascowhite
If you have solved this, please post your solution as an answer and accept it. - vascowhite

1 Answers

0
votes

I have 2 forms classes. First form is the main form and the second form, it is the i want add dynamic. In controller I check how many new elements appeared to form

count($request->getParam('subForm'))

previously using

$subForm->setElementsBelongTo('subForm')

and add new subforms in controller and save it.