Associating label and radio button in Rails

后端 未结 2 1476
孤街浪徒
孤街浪徒 2021-01-02 01:24

I\'m using Rails 2.3.8. My code:

<%= f.radio_button :status, \"draft\" %>
<%= f.label :status, \"Draft\" %>
<%= f.radio_button :status, \"publ         


        
2条回答
  •  庸人自扰
    2021-01-02 02:26

    This worked for me, where I was looping through plans:

    <% @plans.each do |plan| %>
        <%= radio_button_tag :plan_id, plan.id %> 
        <%= label_tag 'plan_id_' + plan.id.to_s, plan.name %>
    <% end %>
    

提交回复
热议问题