Zend表格显示组装饰器

Mar*_*tin 4 zend-framework decorator zend-form

我想知道如何从显示组中删除标签,当你看下面的标记时,你会看到有一个带有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>
Run Code Online (Sandbox Code Playgroud)

谢谢,
马丁

ste*_*vee 8

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

$form->setDisplayGroupDecorators(array(
    'FormElements',
    'Fieldset',
));
Run Code Online (Sandbox Code Playgroud)

注意:这只会改变以前定义的显示组.


小智 5

removeDecorator参数Zend_Form_Decorator_DtDdWrapper不起作用,所以我使用:

$group = $form->getDisplayGroup('the name of the group');
$group->removeDecorator('DtDdWrapper');
Run Code Online (Sandbox Code Playgroud)