Zend表格显示组装饰器

时间:2011-02-10 15:17:24

标签: zend-framework zend-form decorator

当我查看时,我试图找出如何从显示组中删除标签 下面的标记你会看到有一个带有id地址标签的dt以及下面的dd,我想删除这些但保留 字段集。

要添加显示组,我在其中使用此$this->addDisplayGroup(array(...), 'legend' => 'address'); 我添加了每个元素后,我的表单init类。是否有一些装饰我可以玩删除 我不想要的元素?

<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>

谢谢,
马丁

4 个答案:

答案 0 :(得分:8)

如果要将其应用于定义的所有Zend表单显示组(对于特定表单),更简洁的方法是:

$form->setDisplayGroupDecorators(array(
    'FormElements',
    'Fieldset',
));

注意:这只会改变先前定义的显示组。

答案 1 :(得分:5)

removeDecorator参数Zend_Form_Decorator_DtDdWrapper无效,因此我使用了:

$group = $form->getDisplayGroup('the name of the group');
$group->removeDecorator('DtDdWrapper');

答案 2 :(得分:1)

因此您无需单独手动从每个显示组中删除DtDd,您可以使用:

foreach ($this->_displayGroups as $dg){
            $dg->removeDecorator('DtDdWrapper');
        }

答案 3 :(得分:0)

那是什么交易?

$group = $form->getDisplayGroup ('the name of the group');
$group->removeDecorator ('Zend_Form_Decorator_DtDdWrapper');