Topic: Invalid XHTML with multiple forms

If you are looping through a bunch of records displaying them but also want to do some action  you have a form for each one such as:

<% persons.each do |person| %>
  <% form_for :person, person, :url => { :action => "update" } do |f| %>
  <%= f.check_box(:subscribe, {:onchange => 'submit()'}) %>
  <% end %>
<% end %>

If there were two persons it would generate something like:
<form action="/person/subscribe/1" method="post">
  <input checked="checked" id="person_subscribe" name="person[subscribe]" onchange="submit()" type="checkbox" value="1" />
  <input name="person[subscribe]" type="hidden" value="0" />
</form>

<form action="/person/subscribe/2" method="post">
  <input checked="checked" id="person_subscribe" name="person[subscribe]" onchange="submit()" type="checkbox" value="1" />
  <input name="person[subscribe]" type="hidden" value="0" />
</form>


notice the two checkboxes with ids of person_subscribe. IDs are supposed to be unique on a page and therefore the W3 Validator throws up an error. I've tried adding an :id to the checkbox but it has no effect.

So is there anyway around this and/or should I submit this as a bug?

Thanks,
Phil

Re: Invalid XHTML with multiple forms

Any reason you can make it just one form? I would assume you hit the submit button once. Something like:

[code html]
    <form action="/person/subscribe" method="post">
      <input checked="checked" id="1" name="person[subscribe]" onchange="submit()" type="checkbox" value="1" />
      <input name="person[subscribe]" type="hidden" value="0" />

      <input checked="checked" id="2" name="person[subscribe]" onchange="submit()" type="checkbox" value="1" />
      <input name="person[subscribe]" type="hidden" value="0" />
    </form>

[/code]

just changing the id field to the actual number instead of on the form action?

just a thought.

matthewvb