I am trying to figure our how to remove the label from a display group, when you look at the markup below you will see that there is a dt with the id address-label and the following dd, I want to remove these but keep the fieldset.
To add the display group I am using this $this->addDisplayGroup(array(...), 'legend' => 'address');
within
my form init class after I have added each of the elements. Are there some decorators I can play with to remove
the element I dont want?
<form id="CreateAddress" enctype="application/x-www-form-urlencoded" action="" method="post">
<dl class="zend_form">
<dt id="address-label"> </dt>
<dd id="address-element">
<fieldset id="fieldset-address">
<legend>Address</legend>
<dl>
<dt id="addressLine1-label">
<label for="addressLine1" class="required">Address Line 1</label>
开发者_Python百科 </dt>
<dd id="addressLine1-element">
<input type="text" name="addressLine1" id="addressLine1" value="">
</dd>
...etc...
</fieldset>
</dd>
...buttons...
</dl>
</form>
Thanks,
MartinIf you want to apply it to all Zend Form Display Groups defined (for a particular form), a neater way is:
$form->setDisplayGroupDecorators(array(
'FormElements',
'Fieldset',
));
NOTE: this only alters previously defined Display Groups.
The removeDecorator
parameter Zend_Form_Decorator_DtDdWrapper
didn't work so I used:
$group = $form->getDisplayGroup('the name of the group');
$group->removeDecorator('DtDdWrapper');
So that you don't have to manually remove the DtDd's from each display group individually, you can use:
foreach ($this->_displayGroups as $dg){
$dg->removeDecorator('DtDdWrapper');
}
So what's the deal?
$group = $form->getDisplayGroup ('the name of the group');
$group->removeDecorator ('Zend_Form_Decorator_DtDdWrapper');
精彩评论