« Return to Thread: Zend_Form : Subforms, dynamic element creation and best practices

Re: Zend_Form : Subforms, dynamic element creation and best practices

by maxarbos :: Rate this Message:

Reply to Author | View in Thread


Matthew Weier O'Phinney-3 wrote:
> Matthew Weier O'Phinney-3 wrote:
> >
> > Yes. Create an element for each child, and attach each with a different
> > form element name:
> >
> >     foreach ($children as $key => $child) {
> >         $form->addElement('text', 'child' . $key, array('value' =>
> > $child'));
> >     }
> >
> >

So since all of my elements are being created in the init() method and that seems to run even before the __construct , how to I get the value to $children ?

If i call $renderform = new TestForm() from my Controller, the form is already built by the time I try to set the $children by $renderform->children = array('aaa', 'bbb', 'ccc');

I have been following the tutorials at: http://blog.astrumfutura.com/archives/360-Example-Zend-Framework-Blog-Application-Tutorial-Part-6-Introduction-to-Zend_Form-and-Authentication-with-Zend_Auth.html

Is this still the recommended way to create a form with my needs?

 « Return to Thread: Zend_Form : Subforms, dynamic element creation and best practices