<% @fixture.each do |data| %>
<% num = 1 %>
<%= data.matchdate %> |
<%= radio_button_tag(num,data.team ,:checked =>true) %><%= label
:team, data.team %> |
<%= radio_button_tag(num,data.winteam) %><%= label :team,
data.winteam %> |
<% num = num + 1 %>
</tr>
<% end %>
how to work on params of radio button in case of multiple rows? for one
row
i can do it using params[num].
please suggest.
thanks
Jai
<% end %>
how to work on params of radio button in case of multiple rows? for one row i
can do it using params[num].
First off, I am reasonably sure that giving a form field a numerical
name is going to fail, although I am not 100% sure that Rails doesn’t do
something clever about that. I know that in HTML, the ID attribute may
never start with a number, not sure about the name attribute, though.
Second, if you want all of these choices to arrive at the server in a
meaningful chunk, your best bet is to name them so that the browser will
treat the value assignments like a nested hash, rather than a bunch of
dissociated individual values. Take a look at this form submission in
your console while it’s running in development. What do you see in the
params hash that prints out as the form is submitted?
Do your teams have a corresponding ID? Why not use that as your key,
rather than the manually-incremented num?
Walter