Zend_Form:向单选按钮添加元素
我正在尝试在表单中的单选按钮后面添加 Zend_Form_Elements,但到目前为止我还无法这样做。如果有人能指出我正确的方向,我将不胜感激。表单需要渲染如下图:
(*) [____]%
( ) [____]€
( ) [___] for [___]
I'm trying to add Zend_Form_Elements following the radio buttons in my form, but so far I have been unable to do so. If anyone could point me in the right direction it would be greatly appreciated. Form needs to be rendered as shown below:
(*) [____]%
( ) [____]€
( ) [___] for [___]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的事情怎么样:
}
对于非常具体的渲染,@iznogood 是对的:必须进入所有装饰器业务。
How about something like this:
}
For very specific rendering, @iznogood is right: gotta get into all that the decorator business.
使用表单 装饰器 和 css 根据需要设置输入样式。
您可以使用表单装饰器来重写表单的标记。但坦率地说,这是一个相当大的挑战,也许你最好的选择是表单 viewScript。实现起来非常容易,并且可以让您对表单的 html 进行 100% 的控制。查看
示例:使用 ViewScript 装饰器进行完全自定义
在我链接的示例中。
Use form decorators and css to style the input as you want.
You woulduse a forn decorator to rewrite the markup for your form. But its quite a challenge franckly and maybe your best bet is a form viewScript. There very easy to implement and give you 100% control over the html for the form. Look at
Example: Full Customization Using the ViewScript Decorator
In the example I linked.
如果只是定位输入标签的问题,您可以使用 docorators。您可以通过覆盖/修改默认的 FormElements 装饰器来做到这一点,例如,通过向特定表单元素添加 float: left 样式属性。继续 David 的示例:
还有一个 setDefaultDecorators() 方法,它允许您覆盖整个表单中的所有元素装饰器。
如果要创建复合元素,则更高级的解决方案 - http://weierophinney.net /matthew/archives/217-Creating-composite-elements.html - 即包含多个输入标签的自定义表单元素。这样您就可以更好地控制表单业务逻辑。
You could use docorators if it is only a matter of positioning input tags. You can do that by overwriting/modifying default FormElements decorator, for example, by adding float: left style property to particular form element. Continuing from David's example:
There is also a setDefaultDecorators() method, that allows you to overwrite all elements decorators in entire form.
More advanced solution if to create composite elements - http://weierophinney.net/matthew/archives/217-Creating-composite-elements.html - i.e. custom form element containing multiple input tags. You have more control over your form business logic that way.