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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:49:35+00:00 2026-05-31T11:49:35+00:00

I’m still trying to get my form working using Ryan Bates Nested_fom plugin. The

  • 0

I’m still trying to get my form working using Ryan Bates Nested_fom plugin. The problem is that I’ve a 2 levels nested form and when I use the f.link_to_add function it only add first level but not the second one dynamically…

When I click on the Add link, it only creates a new line for 1st level of nesting but not the 2 attached 2nd nested level ones…

For your information model is: :pinvoices has many :pinvlines (first nesting level) and :pinvlines has many :lignes (second nesting level).

Here is the code of the main form:

<%= javascript_include_tag 'javascript_pinvlines_fields_new' %>
<%= nested_form_for @pinvoice do |f| %>
<% if @pinvoice.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@pinvoice.errors.count, "error") %> prohibited this pinvoice from being saved:</h2>
<ul>
<% @pinvoice.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<p>
<%= f.label :contact %>
<%= f.text_field :contact, :id => 'test' %>
<%= f.label :date_facture %>
<%= f.date_select :date_facture %>
<%= f.label :montant_total %>
<%= f.text_field :montant_total %>
<br />
<br />
<div class="lignes">
<%= f.fields_for :pinvlines  %>
</div>
<%= f.link_to_add "Ajouter une ligne", :pinvlines %>
<br />
<p>
<div class="actions">
<%= f.submit %>
</div>
</p>
<% end %>

then here is the partial:

<%= f.label :description %>  
<%= f.text_field :description %>
<%= f.label :compte_id %>
<%= f.collection_select(:compte_id, @compte, :id, :nom, {:prompt => "Type de charge"}) %>
<%= f.label :quantite %>
<%= f.text_field :quantite, :class => "ip", :size => 6 %>
<%= f.label :prix_unitaire %>
<%= f.text_field :prix_unitaire, :class =>"ip", :size => 6 %>
<%= f.label :montant_HTVA %>
<%= f.text_field :montant_HTVA, :size => 6 %>
<%= f.link_to_remove "remove" %>
<p>
<%f.fields_for (:lignes) do |b|%>
<%= b.label :journal_id %><br />
<%= b.text_field :journal_id %>
<%= b.label :compte %><br />
<%= b.text_field :compte %>
<%= b.label :compte_id %><br />
<%= b.text_field :compte_id %>
<%= b.label :montant %><br />
<%= b.text_field :montant %>
</p>
<%end%>

The controller looks like:

def new
@pinvoice = Pinvoice.new
@compte = Compte.find(:all)
1.times do
pinvline = @pinvoice.pinvlines.build
2.times{pinvline.lignes.build}
end

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @pinvoice }
end
end

Is there a genius of Jquery and rails to help me with this highly tricky one… Thanks a lot.

  • 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-31T11:49:37+00:00Added an answer on May 31, 2026 at 11:49 am

    Thanks guys. I’ve finally have done this using the old school way: form_for and fields_for

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

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.