Questions tagged [nested-forms]

A form within another form, often in the ruby-on-rails environment.

This is a Rails gem for conveniently manage multiple nested models in a single form. It does so in an unobtrusive way through jQuery or Prototype.

This gem only works with Rails 3.

Nested forms are when a form is placed within another form, often in the environment.

As of HTML 5, the form element can't be nested. Check section 4.10.18, "Association of controls and forms" for more information.

The platform can also handle nested forms, like the example below:

<div class="form">
    <?php $this->renderPartial('_form', array('form'=>$form)); ?>
    <?php echo $form['user']; ?>
    <?php echo $form['profile']; ?>
    <?php echo $form['subformbuttons']; ?>
</div>

Check the section for general questions and details about forms.

1948 questions
0
votes
1 answer

Unpermitted parameter in Rails 4 when submitted nested attributes, has_many associated form

I have two models (lead which has_many :quote_metals and accepts_nested_attributes_for :quote_metals and quote_metal which belongs_to :lead). I am trying to write the information submitted in the form to the different datatables. There should just…
Joe D
  • 297
  • 1
  • 12
0
votes
1 answer

Rails[Cocoon]: add link persists despite removed field?

I'm on Rails 4 using the latest Cocoon gem. Everything is working perfectly; my only issue is that when I remove nested fields, the add link persists. As in the README, the link for add is in _form while the link for remove is in _[model]_fields.…
Kei
  • 257
  • 3
  • 12
0
votes
1 answer

RoR: Nested Form with Many fields

There are any way to have a nested form which is like: Client has_many address In the Client _form.html.erb there are the normal Client fields and an : <%= f.fields_for :local do |ff| %> to add the address fields too My question is how do i…
0
votes
3 answers

Creating a nested two level form in Rails

I have a Restaurant model that has many DishCategory's and also has many Dish's through DishCategory's. So for instance, the category Dinner would be a number of dishes associated with it. To help build the form I'm using the cocoon gem. I'm…
Carl Edwards
  • 11,370
  • 7
  • 46
  • 88
0
votes
2 answers

Add entry to table consisting only of parent model id

I have two models in an app: Person and Director; person has_one director. A person can be many things (officer, contractor etc AND director); if they are a director I simply want to store their user id in the directors table and nothing more. The…
0
votes
5 answers

Ruby on rails: fields_for do nothing if defined submodel_attributes=

I have such code in new.erb.html: <% form_for(@ratification) do |f| %> <%= f.error_messages %> <% f.fields_for :user do |fhr| %>

<%= fhr.label :url %>
<%= fhr.text_field_with_auto_complete :url %>

<% end…
petRUShka
  • 9,231
  • 12
  • 54
  • 86
0
votes
1 answer

How to insert data from nested form to 2 tables rails 4

I know this question has been asked number of times so far and I have tried figured out my solution from them but none of them worked for me. Since I am learning rails and newbie in this open source world so its very hard for me to get this…
user5084534
0
votes
0 answers

Error in nested_form when rendering page after submiting form with remotipart

The Application: In my Rails (v3.2.17) project I have classes: class User < ActiveRecord::Base has_many :photos, dependent: :destroy accepts_nested_attributes_for :photos, :allow_destroy => true attr_accessible photos_attributes and: class…
evedovelli
  • 2,055
  • 25
  • 27
0
votes
1 answer

Rails Simple_form - edit + show page duplicating nested form every time Its clicked

I am working on a basic web app, and one of the requirements is a Profile page with a nested form. The nested form is a model called experience, which basically asks the user if they had previous work experience or not and asking for basic…
0
votes
1 answer

How to manually build a correct nested form with accepts_nested_attributes_for?

I'm trying to manually build form fields for a testing purpose. I got the following models: class Bedroom < ActiveRecord::Base has_many :booked_bedrooms has_many :bookings, :through => :booked_bedrooms end class Booking <…
pdu
  • 9,917
  • 4
  • 53
  • 87
0
votes
1 answer

Creating a object with nested form rails

I have 3 tables: members, meetings, meeting_has_members. The models are: member.rb class Member < ActiveRecord::Base has_many :meeting_has_members has_many :meetings, through: :meeting_has_members accepts_nested_attributes_for…
0
votes
1 answer

Rails 4.2 has_many through in-place editing nested form with xeditable

I have the following list of models in a Rails 4.2 app: User Company Marketplace The associations look like the following: User.rb class User < ActiveRecord::Base end Company.rb class Company < ActiveRecord::Base has_many…
cnikolaou
  • 3,414
  • 4
  • 23
  • 31
0
votes
1 answer

Facing issue in f.link_to_add in gem "nested_form"

Hi I am using gem "nested_form" and in my view I have given like this <%= f.fields_for :tasks do |task_form| %> <%= task_form.text_field :name %>
<%= task_form.text_field :rate %> <% end %>

<%=…

Dinshaw Raje
  • 849
  • 10
  • 31
0
votes
1 answer

Rails - HABTM find or create nested form

I found this. My question is now how do I create the form, I am trying: #students.row = f.fields_for :classrooms_students, f.object.classrooms_students do |cs| = cs.fields_for :student, cs.object.student do |s| …
sites
  • 19,991
  • 16
  • 81
  • 136
0
votes
2 answers

Nested form attributes

I have one form working to save in the database but I want to save some fields that are going to be saved in a different record. <%= form_for @complaint, url: {action: 'create'}, :html => {:multipart => true} do |f| %> <%= f.text_field…
Johhan Santana
  • 1,876
  • 3
  • 27
  • 53