Multimodel Forms plugin

Plugin details

This allows one form to have fields from different models within it.

Websitehttp://code.google.com/p/multimodel-forms/ Repositoryhttp://multimodel-forms.googlecode.com/svn/trunk/multimodel_forms/ Author Michael Murray Tags form LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://multimodel-forms.googlecode.com/svn/trunk/multimodel_forms/

=== example
post.rb

class Post < ActiveRecord::Base
  has_many_with_attributes :links
end



photo.rb

class Photo < ActiveRecord::Base
  belongs_to :article
end


Can now add a view partial to render the post form and edit the associated photos.

post/_form.rhtml

Title
<%= f.text_field :title %>

Photo

  <%= render :partial => 'photos/photo', :collection => @post.photos %>


<%= add_link "Add photo", :photo %>



photos/_photo.rhtml

<% fields_for_associated :post, link do |l_form| %>
  <%= l_form.text_field :url, :index => nil %>
  <%= delete_link_for(link, "Delete", l_form) %>
<% end %>

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, 8 months ago