Hi - I think I'm seeing a bug in rails but am not sure. Maybe I'm just struggling. Could somebody take a look at this?
I have a form to enter runner's times for an ultra marathon. The form has 20 rows so we can enter 20 runners times at one submit. Each row has the fields bibNumber, dayIn, timeIn, dayOut, and timeOut where we record the times that a runner enters and departs a check point. I am using radio buttons for the user to select the dayIn and dayOut fields and the available choices are "Fri", "Sat", or "Sun", as it's a 48 hour race spanning Friday 6am through Sunday 6am.
In my generated html, I can't get both the id attribute and the name attribute to be indexed at the same time. I get either one but not both depending on how I use the radio_button() helper.
If I use the following code in my partial, I see the subsequent html:
code: <%= radio_button(:runner_time, :dayIn, "Fri", {:index => runner_time_counter}) %><br/> <%= radio_button(:runner_time, :dayIn, "Sat", {:index => runner_time_counter}) %> <br/> <%= radio_button(:runner_time, :dayIn, "Sun", {:index => runner_time_counter}) %>
html: <input id="runner_time_dayIn_fri" name="runner_time[0][dayIn]" type="radio" value="Fri" /><br/> <input id="runner_time_dayIn_sat" name="runner_time[0][dayIn]" type="radio" value="Sat" /><br/> <input id="runner_time_dayIn_sun" name="runner_time[0][dayIn]" type="radio" value="Sun" />
Notice the id isn't indexed, so on a form with 20 rows of this, my <label for=""> tags can't reference unique radio buttons, they all end up referencing the top one.
I have noticed if I use the following code, the id is indexed (or unique), but the name isn't so my data isn't submitted correctly:
code: <%= radio_button(:runner_time, :dayIn, :value => "Fri", :index => runner_time_counter) %> <br/> <%= radio_button(:runner_time, :dayIn, :value => "Sat", :index => runner_time_counter) %> <br/> <%= radio_button(:runner_time, :dayIn, :value => "Sun", :index => runner_time_counter) %>
html: <input id="runner_time_dayIn_index0valuefri" name="runner_time[dayIn]" type="radio" value="index0valueFri" /> <br/> <input id="runner_time_dayIn_index0valuesat" name="runner_time[dayIn]" type="radio" value="index0valueSat" /> <br/> <input id="runner_time_dayIn_index0valuesun" name="runner_time[dayIn]" type="radio" value="index0valueSun" />
Does anybody know how I get the id and name to be indexed so this page will work?
Thank you! Steve