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>
</dt>
<dd id="addressLine1-element">
<input type="text" name="addressLine1" id="addressLine1" value="">
</dd>
...etc...
</fieldset>
</dd>
...buttons...
</dl>
</form>
Thanks,
Martin
If 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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With