Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails plugin to conveniently handle multiple models in a single form.
Ruby CSS JavaScript
#322
Branch: rails2
#322 Compare This branch is 1 commit ahead, 226 commits behind master.
Failed to load latest commit information.
lib apply all callbacks for content after nested form
spec apply all callbacks for content after nested form
LICENSE
README.rdoc updating readme
Rakefile initial import
init.rb initial import
install.rb generate nested_form.js file when installing plugin, could use some work

README.rdoc

Nested Form

This branch is for Rails 2 and no longer maintained. Instead use the master branch with Rails 3.

A Rails plugin to conveniently manage multiple nested models in a single form. It does so in an unobtrusive way through jQuery.

This is in early development, so some of this documentation is not yet applicable.

Install

This is currently only available as a plugin.

script/plugin install git://github.com/ryanb/nested_form.git -r rails2

Usage

When installing this plugin it will add a file at public/javascripts/nested_form.js which should be included after jQuery.

<%= javascript_include_tag 'jquery', 'nested_form' %>

You can then generate a nested form using the nested_form_for helper method.

<% nested_form_for @project do |f| %>

Use this form just like normal, including the fields_for helper method for nesting models. The benefit of this plugin comes from the link_to_add and link_to_remove helper methods on the form builder.

<% f.fields_for :tasks do |task_form| %>
  <%= task_form.text_field :name %>
  <%= task_form.link_to_remove "Remove this task" %>
<% end %>
<%= f.link_to_add "Add a task", :tasks %>

This generates links which dynamically add and remove fields.

Special Thanks

This plugin is based on the solution by Tim Riley in his complex-form-examples fork.

github.com/timriley/complex-form-examples/tree/unobtrusive-jquery-deep-fix2

Something went wrong with that request. Please try again.