I am using the simple_form gem https://github.com/plataformatec/simple_form to create some input fields; one of which is a radio button group, like this:
<%= f.input :due_date, :collection => ['Today', 'Tomorrow', 'In 3 Days'], :as => :radio %>
So this field in the database "due_date" is a Date. But rather than letting people click on that smallish calendar, we know that generally people just want these three options. And I do want to use radio button. But the output of this line suggest that if I hit the submit button now, the due_date param will have the values stated there, i.e., Today, Tomorrow or In 3 Days. Here's the output HTML for the Today part.
<span>
<input class="radio optional" id="project_due_date_today" name="project[due_date]" type="radio" value="Today">
<label class="collection_radio" for="project_due_date_today">Today</label>
</span>
What I want ideally is like :
<%= f.input :due_date, :collection_to_params => [Date.today, Date.tomorrow, Date.today+3], :display_value => ['Today', 'Tomorrow', 'In 3 Days'], :as => :radio %>
So when a user clicks on one, and submits, I actually get some ISO date sent to the server.
Any ideas?
Thanks!
simple_form
, but usually with Rails it's worth trying a hash::collection => {'Today' => Date.today, 'Tomorrow' => Date.tomorrow, 'In 3 Days' => Date.today+3}
– Megasporangiumradio
is deprecated, and replaced to aradio_buttons
. – Magnific