使用 Zend_Form 将多个元素组添加到一个显示组中

发布于 2024-11-18 16:13:18 字数 1507 浏览 7 评论 0原文

我正在使用 Zend_Form 输出我的表单,并且我正在尝试对 s 内的按钮元素进行分组,然后将它们添加到字段集中。

我管理的最好的结果是:

<fieldset id="fieldset-group1">
    <div class="buttons">
        <button name="submit_form" id="submit_form" type="submit">Submit</button>
        <button name="cancel_form" id="cancel_form" type="submit">Cancel</button>
    </div>
</fieldset>
<fieldset id="fieldset-group2">
    <div class="buttons">
        <button name="reset_form" id="reset_form" type="submit">Reset</button>
        <button name="button_form" id="button_form" type="button">Button</button>
    </div>
</fieldset>

两个元素组位于两个单独的显示组内。我通过将 DisplayGroup HtmlTag 装饰器“tag”选项设置为“div”来完成此操作。

我想要实现的是:

<fieldset id="fieldset-group1">
    <div class="buttons">
        <button name="submit_form" id="submit_form" type="submit">Submit</button>
        <button name="cancel_form" id="cancel_form" type="submit">Cancel</button>
    </div>

    <div class="buttons">
        <button name="reset_form" id="reset_form" type="submit">Reset</button>
        <button name="button_form" id="button_form" type="button">Button</button>
    </div>
</fieldset>

两个 div 位于一个显示组内。

我希望我可以使用 HtmlTag 装饰器可用的“openOnly”和“closeOnly”选项,但它们不适用于 DisplayGroups。

除了扩展 Zend_View_Helper_Fieldset 来执行我想要的操作之外,还有更好的方法吗?

I'm using Zend_Form to output my form and I am trying to group button elements within 's and then add them to a fieldset.

The best I have managed is:

<fieldset id="fieldset-group1">
    <div class="buttons">
        <button name="submit_form" id="submit_form" type="submit">Submit</button>
        <button name="cancel_form" id="cancel_form" type="submit">Cancel</button>
    </div>
</fieldset>
<fieldset id="fieldset-group2">
    <div class="buttons">
        <button name="reset_form" id="reset_form" type="submit">Reset</button>
        <button name="button_form" id="button_form" type="button">Button</button>
    </div>
</fieldset>

where the two element groups are within two separate display groups. I have done this by setting the DisplayGroup HtmlTag Decorator 'tag' option to 'div.

What I am looking to achieve is this:

<fieldset id="fieldset-group1">
    <div class="buttons">
        <button name="submit_form" id="submit_form" type="submit">Submit</button>
        <button name="cancel_form" id="cancel_form" type="submit">Cancel</button>
    </div>

    <div class="buttons">
        <button name="reset_form" id="reset_form" type="submit">Reset</button>
        <button name="button_form" id="button_form" type="button">Button</button>
    </div>
</fieldset>

where the two div's are within the one display group.

I was hoping I could use the 'openOnly' and 'closeOnly' options that are available to the HtmlTag Decorator, but they are not available for DisplayGroups.

Apart from extending the Zend_View_Helper_Fieldset to do what I want is there a better way of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请止步禁区 2024-11-25 16:13:18
'decorators'=>array('FormElements',
                     array(array('divtag'=>'HtmlTag'),'options'=>array('tag'=>'div')),
                     array(array('fstag'=>'HtmlTag'),'options'=>array('tag'=>'fieldset','openOnly'=>true)),
                   )

openOnly/closeOnly 也可以与 DisplayGroups 一起使用

'decorators'=>array('FormElements',
                     array(array('divtag'=>'HtmlTag'),'options'=>array('tag'=>'div')),
                     array(array('fstag'=>'HtmlTag'),'options'=>array('tag'=>'fieldset','openOnly'=>true)),
                   )

openOnly/closeOnly can be used with DisplayGroups too

各自安好 2024-11-25 16:13:18

他们总是说你可以编写自己的装饰器。您要做的不是扩展 view_helper 而是编写您自己的装饰器。这里的装饰器不是 fieldset afaik 而是 fieldset 内部并由 fieldset 使用的 FormElements。它是 FormElements 装饰器,其设计目的不是处理您正在寻找的 div。

They always say you can write your own decorators. What you have to do is not extend the view_helper but write your own decorator. The decorator here is not the fieldset afaik but the FormElements inside and used by fieldset. It is the FormElements decorator which is not design to handle the div's you are looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文