Reputation: 5073
I have a checkbox below. It's rendering properly (unchecked) but submitting with a value of "1". I want the unchecked boxes to have default values of 0.
<%= builder.check_box :content, :class=>"yesno", :data => {:'on-text' =>"YES", :'off-text' =>"NO", :question => question.id} %>
Thoughts?
Upvotes: 0
Views: 55
Reputation: 118289
You need to do
<%= builder.check_box :content, {:class=>"yesno", :data => {:'on-text' =>"YES", :'off-text' =>"NO", :question => question.id}}, 0, 1 %>
As per the check_box documentation:
The
checked_value
defaults to 1 while the defaultunchecked_value
is set to 0 which is convenient for boolean values.
Upvotes: 1