Search code examples
phpzend-frameworkzend-formzend-form-sub-form

Zend_Form: Wrap html tags around subforms


Say I have this form:

$this->addElement('select', 'menu');

$subform = new Zend_Form_SubForm();
$subform->addElement('text', 'title');
$subform->addElement('text', 'content');

$this->addSubform($subform, 'bar');

$this->addElement('submit', 'submit');

And I wanted to wrap custom html around the subform like:

<div id="foo">
     <!-- subform here -->
</div>

How would I go about to do that? addSubform() does not take an option parameter like addElement() does.


Solution

  • You can a decorators to subforms.

    $subform-> setSubFormDecorators($decorators);