I was wondering if anyone can help with how to render a single sub form
element in a view script.

I have a Zend_Form_SubForm and I am attaching this same sub form a number of
times in the Controller, to a Zend_Form, e.g.

$form = new Zend_Form();

for ($i = 1; $i <= 5; ++$i) {
        $mysubform = new MySubForm();
        $form->addSubForm($mysubform, 'mysubformname' . $i);
}

In the view script, if I render the parent form <?php echo $this->form ?> I
get the following named elements in the sub form:

<input name="mysubformname1[elementName]"/>
<input name="mysubformname2[elementName]"/>

Which is fine and all is well with the form handling, validation etc.
However, I would like to render the elements individually in the view script
because I need to lay them out in a certain way (too complex for me to use
decorators at the moment).  If I was rendering the Zend_Form elements I
would use:

<?php echo $this->form->elementName ?>

But, what do I use for the sub form?  If I use this:

<?php echo $this->form->getSubForm('mysubformname1')->elementName ?>
<?php echo $this->form->getSubForm('mysubformname2')->elementName ?>
or
<?php echo $this->form->mysubformname1->elementName ?>

I just get (for all):

<input name="elementName">

Any help would be much appreciated.

Thanks

Colin
-- 
View this message in context: 
http://www.nabble.com/Rendering-a-sub-form-element-in-a-view-script-tp21750939p21750939.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to