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

  • Home
  • SEARCH
  • 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 935093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:06:15+00:00 2026-05-15T21:06:15+00:00

I’ve got a rails app that displays a list of items called modules. I’m

  • 0

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?

  • 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-15T21:06:15+00:00Added an answer on May 15, 2026 at 9:06 pm

    Add the :index => object.id to the options hash when creating your form. This should generate ids in the form of object_id_attribute without interfering with the controller.

    Edit

    The documentation regarding :index is is ambiguously misleading. :index does have an effect on the form submission. The solution is to specify the :id attribute for each field. This will change the id property, leaving name unharmed (which is what counts for the submission).

    Here is the code I use in a generic helper for generating these fields:

    def create_field( f, field_type, object, field_name )
        field_id = "#{object.class.name.downcase}_#{object.id.to_s}_#{field_name.to_s}"
        f.send( field_type, field_name, :id => field_id )
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.