Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Form Display Group Decorators

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">&#160;</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

like image 621
Martin Avatar asked Dec 10 '22 11:12

Martin


2 Answers

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.

like image 159
steevee Avatar answered Apr 25 '23 18:04

steevee


The removeDecorator parameter Zend_Form_Decorator_DtDdWrapper didn't work so I used:

$group = $form->getDisplayGroup('the name of the group');
$group->removeDecorator('DtDdWrapper');
like image 37
Sudhir Avatar answered Apr 25 '23 17:04

Sudhir