Rails f.check_box set checked/unchecked values

前端 未结 1 995
野趣味
野趣味 2021-02-05 13:16

so I got a form helper in rails with a checkbox; I want that checkbox to have values as \"thatvalue\" or \"thisvalue\" when checked or unchecked; I haven\'t found anywhere how t

相关标签:
1条回答
  • 2021-02-05 14:05

    ok nevermind, I misunderstood the "options" field...

    the answer is simply

    <%= f.check_box :field, {:class => "myclass", :style => "mystyle"}, "checked-value", "unchecked-value" %>
    

    and it works perfectly :)

    0 讨论(0)
提交回复
热议问题