Multiple remote_form_for on the same page causes duplicate ids
- by Ben Scheirman
I've got a rails app that displays a list of items called modules. I'm iterating over these, rendering a partial for each one that includes a remote_form_for call.
This all works, but fails HTML validation because my form text fields all have the same id.
Is there a :prefix option on the form (or something else) I can use to get around this?
Update:
(some code)
//_module_form.html.erb
<% remote_form_for app_module do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= submit_tag 'Save' %>
<%end %>
//parent page
<% @thing.modules.each do |app_module| %>
<%= render :partial => "module_form", :locals => { :app_module => app_module } %>
<% end %>
So if I have more than 1 item in the collection, I render the identical form on the same page, and the form id and textbox id are duplicated.
I can customize the form id pretty easily, but what about the text_box, since the controller is looking for specific named controls?