使用 Zend_Form 将多个元素组添加到一个显示组中
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
openOnly/closeOnly 也可以与 DisplayGroups 一起使用
openOnly/closeOnly can be used with DisplayGroups too
他们总是说你可以编写自己的装饰器。您要做的不是扩展 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.