[Rails] How to insert a null value into DB using a radio_button with form_for
Hi,
I'm trying to add a third option for a filter using a radio button. It's
the old null-value-for-a-boolean story. Basically i'd like to add
another radio button labelled "No Filter" which would insert a null
value into the database when selected. Here is my first attempt. The
third button is showing up, but the null value is not being inserted.
What am I missing?
<div class="new-partner-form">
<%= form_for [:admin, matching_profile.partner, matching_profile],
:html => {:id => "edit_profile", :multipart => true} do |f| %>
<div class="rounded-block semi-wide clear">
<h4>Military Service</h4>
<%= f.radio_button :served_in_us_army, false %>
<%= label :served_in_us_army, 'NO', {:style => 'display:inline'} %>
<%= f.radio_button :served_in_us_army, true %>
<%= label :served_in_us_army, 'YES', {:style => 'display:inline'} %>
<%= f.radio_button :served_in_us_army, nil %>
<%= label :served_in_us_army, 'No Filter', {:style =>
'display:inline'} %>
<%= f.error_message_on :served_in_us_army %>
</div>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home