Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:44+00:00 2026-05-27T21:46:44+00:00

I have this form_for: <%= form_for [post, Comment.new,], :remote => true do |f| %>

  • 0

I have this form_for:

<%= form_for [post, Comment.new,], :remote => true do |f| %>
<%= f.text_area :content, :cols =>10, :rows => 1%>
<% end %>
<%= f.submit :class => "input_comment"  %>

That generate the next code html:

<form method="post" id="new_comment" data-remote="true" class="new_comment" 
action="/post/4efcda9e1d41c82486000077/comments" accept-charset="UTF-8"><div 
style="margin:0;padding:0;display:inline"><input type="hidden" value="✓" name="utf8">
<input type="hidden" value="ctVfDF/O4FIR91I7bC5MVezQmutOCkX3dcXe73uNPZY=" name="authenticity_token">

<textarea rows="1" name="comment[content]" id="comment_content" cols="10"></textarea>
<input type="submit" value="Create Comment" name="commit" class="input_comment">
</form>

If I have many forms in a same page is not a html valid with the same id.

  • The id for form_for generate id=”new_comment”
  • The id for textarea generate id=”comment_content”

With so many forms in a same page is not valid html.

How can I change the id autogenerate by form_for method helper from rails 3.1?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:46:44+00:00Added an answer on May 27, 2026 at 9:46 pm

    Adding on to what miked said, the easiest way to make unique form id’s for the posts would be to use the post’s id numbers in the id attribute, like so:

    <%= form_for [post, Comment.new,], :remote => true, :html => { :id => "new_comment_on_#{post.id}" } do |f| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this in one of my haml views: -form_for :news_item_comment, :url=>{:id => comment.id,
I have a simple Django form: class CommentForm(forms.Form): comment = forms.CharField(max_length=2000, required=True) post_id =
So i have this form for generating comment_titles: <%= simple_form_for @video, :remote => true
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have a WCF Rest service: [WebHelp(Comment = Sample description for GetData)] [WebInvoke(Method=POST, UriTemplate
So I have this form which requests a JS call when a comment is
For example Imagine I have the following form <%= form_for(@comment) do |f| %> <%=
If I have a model named Client and controller that looks like this class
Le HTML: <form action=/comment_replies/ajax_create/30?type=2 id=new_comment_2_30 method=post onsubmit=new Ajax.Request('/comment_replies/ajax_create/30?type=2', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;> <textarea
So, I'm pretty new to all this network programming, and I have a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.