Issue
What is the simplest way to represent an integer attribute with a limited number of valid values as radio buttons?
How can I use the formhelper to achieve this? I only see examples that use string values.
Solution
You can try
<%= form_for :model do |f| %>
<% 1.upto(10) do |i| %>
<%= f.radio_button :integer, i %> #integer is the model field
<% end %>
<% end %>
or
<%= form_tag do %>
<% 1.upto(10) do |i| %>
<%= radio_button_tag :name, i %>
<% end %>
<% end %>
Answered By - Rajarshi Das Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.