根据(有点官方)
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.
感谢阅读,也许还有帮助!