I have this form_for:
<%= form_for [post, Comment.new,], :remote => true do |f| %>
<%= f.text_area :content, :cols =>10, :rows => 1%>
<%
I think the :namespace
option is what you're looking for.
It appends the name to the form's id as well as all input and label fields.
e.g
<%= form_for [post, Comment.new,], namespace: 'NAMESPACE', :remote => true do |f| %>
<%= f.text_area :content, :cols =>10, :rows => 1%>
<% end %>
Would generate:
Form id = NAMESPACE_new_comment
Textarea id = NAMESPACE_comment_content
From the docs:
:namespace - A namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generated HTML id