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 6010007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:03:15+00:00 2026-05-23T02:03:15+00:00

I need to make a form that will submit an array of records. I

  • 0

I need to make a form that will submit an array of records. I am using rails 2.3.11 and trying to follow the instructions in the one to many section here: http://api.rubyonrails.org/v2.3.8/classes/ActionView/Helpers/FormHelper.html

However when I do it, I get errors, or the form only submits the last record in the array.

This doesn’t work, because @query[:filters] is an array, so fields_for will throw an exception:

  <% form_for :aquery, @query, :url => {:action => 'index'} do |a| %>
    <% a.fields_for :filters, @query[:filters] do |f| %>
      <p>
        <%= f.select :field, @fields %>
        <%= f.select :logic, ["all", "is", "is not", "none"]%>
        <%= f.text_field :arg, :size => 30 %>
      </p>
    <% end %>
    <%= submit_tag l(:button_apply) %>
  <% end %>

This doesn’t work because it ignores the contents of @query[:filters], and only renders one set of fields regardless of how large the array is:

    <% a.fields_for :filters do |f| %>

And this doesn’t work because it will only submit the last item in the array:

<% form_for :aquery, @query, :url => {:action => 'index'} do |a| %>
  <% @query[:filters].each do |filter| %>
    <% a.fields_for :filters, filter do |f| %>
      <p>
        <%= f.select :field, @fields %>
        <%= f.select :logic, ["all", "is", "is not", "none"]%>
        <%= f.text_field :arg, :size => 30 %>
      </p>
    <% end %>
  <% end %>
  <%= submit_tag l(:button_apply) %>
<% end %>
  • 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-23T02:03:16+00:00Added an answer on May 23, 2026 at 2:03 am

    You need to run over your filters and do the indexing manually.

    <% form_for :aquery, @query, :url => {:action => 'index'} do |a| %>
      <% @query[:filters].each_with_index do |filter, i| %>
        <% a.fields_for :filters, filter, :index => i do |f| %>
          <p>
            <%= f.select :field, @fields %>
            <%= f.select :logic, ["all", "is", "is not", "none"]%>
            <%= f.text_field :arg, :size => 30 %>
          </p>
        <% end %>
      <% end %>
      <%= submit_tag l(:button_apply) %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to to make a form that will submit a new record and
I want to make a form that will use jquery to submit a list
I need to make a Rails form that responds back to the user live
I need to make a form with a Text Area that accepts lines of
I need to make sure that user can run only one instance of my
I have an ASP website and I need to add a form that will
I need to make some reflective method calls in Java. Those calls will include
I am (trying) to build a web app, first one :) I need to
I've been using Werkzeug to make WSGI compliant applications. I'm trying to modify the
Here's what I'm trying to do. When the 'Submit' form is clicked on my

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.