【问题标题】:Zend Form Display Group DecoratorsZend 表单显示组装饰器
【发布时间】:2011-06-24 22:32:27
【问题描述】:

当您查看 下面的标记你会看到有一个带有 id address-label 的 dt 和下面的 dd,我想删除这些但保留 字段集。

要添加我正在使用这个$this->addDisplayGroup(array(...), 'legend' => 'address');的显示组 添加每个元素后,我的表单初始化类。是否有一些装饰器可以用来移除 我不想要的元素?

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

谢谢,
马丁

【问题讨论】:

    标签: zend-framework zend-form decorator


    【解决方案1】:

    那么交易是什么?

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        这样您就不必手动从每个显示组中单独删除 DtDd,您可以使用:

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

        【讨论】:

          【解决方案4】:

          如果你想将它应用到所有定义的 Zend 表单显示组(针对特定表单),一个更简洁的方法是:

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

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

          【讨论】:

            猜你喜欢
            • 2011-01-10
            • 2012-10-23
            • 2011-07-13
            • 2011-01-24
            • 1970-01-01
            • 2012-04-18
            • 2011-08-08
            • 2011-10-07
            • 1970-01-01
            相关资源
            最近更新 更多