I'm displaying a table of radio buttons, each of which corresponds to a recipe with a unique id. I'm using a submit tag to submit exactly which radio button was pressed, indicating which recipe was selected. I'm trying to pass the id to my controller to make some queries/form fields. I'm having trouble actually passing the id. Can someone help me out, I'm a Ruby newbie? Thanks!
<%= form_tag(:action => 'chooseOption') do %>
<%= submit_tag("Show Recipe", :class => 'action show') %>
<%= submit_tag("Delete Recipe", :class => 'action delete') %>
<td><%= radio_button_tag 'recipe', recipe, @recipe == recipe %></td>
<td>recipe.recipe_name</td>
<td>recipe.total_calories</td>
.....all the other fields
</td>
See
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-radio_button
Also
http://guides.rubyonrails.org/form_helpers.html
Section 1.3.2, radio_button_tag
And last but not least,
Labels for radio buttons in rails form
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With