在 Zend Form 中的单选按钮旁边放置一些 HTML
我已经构建了一个表单生成器,并且我需要能够为单选元素中的每个选项分配描述。创建此单选元素后,我要求用户为每个值分配一个描述,该描述应显示在元素旁边。 因此,在我的数据库中,该单选元素中的每个选项都有一个值、标题和说明。
问题: 如何在无线电元素旁边放置一些东西?我是否必须为表单创建一种新的方式来渲染无线电元素,或者可以通过装饰器来完成吗?
任何一点帮助,也欢迎有用的阅读!
我需要的代表:
**A title of the Radio element**
O Option 1 - A description for option 1
O Option 2 - A description for option 2
O Option 3 - A description for option 3
O Option 4 - A description for option 4
有什么想法吗?
I have built a form builder, and I need the ability to assign description to every option in a radio element. Upon creation of this radio element, I ask the user to assign each value a description, which should be shown next to the element. So, in my database, I have a value, a title and a description for each option in this radio element.
The question:
How do I put something next to a radio element? Do I have to create a new way for the form to render radio elements, or can it be done via decorators?
Any little bit helps, useful reading is welcome too!
A representation of what i need:
**A title of the Radio element**
O Option 1 - A description for option 1
O Option 2 - A description for option 2
O Option 3 - A description for option 3
O Option 4 - A description for option 4
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很难从您的问题中看出,但是标记中实际的单选按钮在哪里?
如果它位于选项标签的左侧或右侧,您只需使用该标签输入额外的标记并将 ViewHelper 的
escape
属性设置为false
即可启用 HTML例如
看起来像这样
It's hard to tell from your question but where abouts is the actual radio button in your markup?
If it's to the left or right of the option label, you can simply use the label to enter your extra markup and set the ViewHelper's
escape
property tofalse
to enable HTMLFor example
Looks like this
查看我编写的解决此问题的教程。
http://wesleyalmeida.net/我学到了什么/如何在 zend 中装饰无线电元素/
Check out the tutorial I wrote solving this problem.
http://wesleyalmeida.net/what-ive-learned/how-to-decorate-a-radio-element-in-zend/