开发者

Ruby on Rails -- assign a value to a checkbox

开发者 https://www.devze.com 2023-02-07 18:43 出处:网络
I want to assign a value to a checkbox. The code below doesn\'t seem to work Same Section <%= f.check_box 开发者_StackOverflow社区:LSU_TYPE,:value =>\"Same Section\" %>

I want to assign a value to a checkbox. The code below doesn't seem to work

Same Section <%= f.check_box 开发者_StackOverflow社区:LSU_TYPE,  :value =>"Same Section" %>

Instead of storing 'Same Section' in the table, value '1' is stored when i check the box.

What am i doing wrong here?


A checkbox is a boolean field. It can only accept 1 or 0, 'True' or 'False'.


@Kum this works for me:

<div><%= f.label :pay_with_card? %></br>
<%= f.check_box :pay_with_card,{}, "Yes", "No"%>  

good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消