在 Zend Framework 中对单选按钮进行分组
我想在逻辑产品组中显示单选按钮:
Broadband products:
(*) 2 Mbit
( ) 4 Mbit
Voice products:
( ) Standard
( ) Total
Bundles:
( ) 4 Mbit + Standard
( ) 4 Mbit + Total
所有单选按钮都具有相同的 name
属性 - 您明白了。 Zend Framework 1.8 似乎不支持以这种方式对单选按钮进行分组。 有什么办法解决这个问题吗?
更新。 只是为了澄清一下,生成的代码应该看起来有点像这样:
Broadband products: <br/>
<input type="radio" name="product" value="1"/> 2 Mbit <br/>
<input type="radio" name="product" value="2"/> 4 Mbit <br/>
Voice products: <br/>
<input type="radio" name="product" value="3"/> Standard <br/>
<input type="radio" name="product" value="4"/> Total <br/>
Bundels: <br/>
<input type="radio" name="product" value="5"/> 4 Mbit + Standard <br/>
<input type="radio" name="product" value="6"/> 4 Mbit + Total <br/>
不要介意确切的格式化代码。 只有形式元素才重要。
I want to present radio buttons in logical products groups:
Broadband products:
(*) 2 Mbit
( ) 4 Mbit
Voice products:
( ) Standard
( ) Total
Bundles:
( ) 4 Mbit + Standard
( ) 4 Mbit + Total
All radio buttons have the same name
attribute - you get the idea. It seems that Zend Framework 1.8 does not support grouping radio buttons this way. Is there any solution to this?
Update. Just to clarify, resulting code should look somewhat this way:
Broadband products: <br/>
<input type="radio" name="product" value="1"/> 2 Mbit <br/>
<input type="radio" name="product" value="2"/> 4 Mbit <br/>
Voice products: <br/>
<input type="radio" name="product" value="3"/> Standard <br/>
<input type="radio" name="product" value="4"/> Total <br/>
Bundels: <br/>
<input type="radio" name="product" value="5"/> 4 Mbit + Standard <br/>
<input type="radio" name="product" value="6"/> 4 Mbit + Total <br/>
Nevermind the exact formatting code. Only form elements matter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是对的,ZF 1.8 不支持以这种方式对选项进行分组。 您可以轻松地查看
Zend_View_Helper_FormRadio
中的代码并创建您自己的支持多维数组(即选择分组)的视图助手。 我已经为一个项目执行此操作,请查看 pastebin.comPHP:
生成的 HTML 中的示例:
You're correct that ZF 1.8 doesn't support grouping of options in this way. You could easily look at the code inside
Zend_View_Helper_FormRadio
and create your own view helper that supports a multi-dimensional array (ie the select groupings). I had to do this already for a project, check out the example at pastebin.comPHP:
Resulting HTML:
看看 Zend_Form_Element_Radio
http:// /framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.radio
也有多复选框类,但我想它仅适用于复选框
http://framework.zend。 com/manual/en/zend.form.standardElements.html#zend.form.standardElements.multiCheckbox
Take a look at Zend_Form_Element_Radio
http://framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.radio
There is the multi checkbox class too, but i guess it's only for checkboxes
http://framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.multiCheckbox