I’m using Zend_Form from Zend Framework 1.10.6 to render a html form. In this form ‘z’, there’s a subform with a field ‘a’. The subform is added to the main form twice, once with the name ‘x’ and once as ‘y’.
Below is the html rendered by the Zend_Form-object.
<form id="z" enctype="application/x-www-form-urlencoded" method="post" action="">
<dl class="zend_form">
<dt id="x-label"> </dt>
<dd id="x-element">
<fieldset id="fieldset-x">
<dl>
<dt id="a-label"><label for="x-a" class="required">A</label></dt>
<dd id="a-element"><input type="text" name="x[a]" id="x-a" value="" /></dd>
</dl>
</fieldset>
</dd>
<dt id="y-label"> </dt>
<dd id="y-element">
<fieldset id="fieldset-y">
<dl>
<dt id="a-label"><label for="y-a" class="optional">A</label></dt>
<dd id="a-element"><input type="text" name="y[a]" id="y-a" value="" /></dd>
</dl>
</fieldset>
</dd>
<dt id="submit-label"> </dt><dd id="submit-element"><input type="submit" name="submit" id="submit" value="Submit" /></dd>
</dl>
</form>
The only problem is now that the standard decorator (<dt>, <dd>) generates duplicate IDs. Why aren’t these IDs prefixed with the subform name and a dash, like the IDs of the input fields are?
Not sure why they aren’t prefixed but to get around it, I’d just set my own custom decorators on the elements. This article may help http://devzone.zend.com/article/3450