根据(有点官方)
this guide,我可以制作单选按钮的标签,也可以选择该单选按钮.他们说,
Always use labels for each checkBox and radio button. They associate text with a specific option and provide a larger clickable region.
<% form_for(@bet) do |f| %> <%= f.label :bet_type %> <%= f.radio_button :bet_type,"moneyline" %> <%= f.label :bet_type_moneyline,"Moneyline" %> <%= f.radio_button :bet_type,"spread" %> <%= f.label :bet_type_spread,"Spread" %> <% end %>
我也尝试了这个(因为这是使用FormTagHelper而不是FormHelper的示例):
<% form_for(@bet) do |f| %> <%= radio_button_tag :bet_type,"moneyline" %> <%= label_tag :bet_type_moneyline,"Moneyline" %> <%= radio_button_tag :bet_type,"spread" %> <%= label_tag :bet_type_spread,"Spread" %> <% end %>
但是,我仍然无法让它发挥作用.我正在使用rails 2.3.5和ruby 1.8.7.
感谢阅读,也许还有帮助!
解决方法
原文地址:https://www.jb51.cc/html/226275.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。