Created
April 7, 2012 21:55
-
-
Save dreamwieber/2332370 to your computer and use it in GitHub Desktop.
Cocoon form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's what the form looks like: | |
<%= simple_form_for @album do |f| %> | |
<% if @album.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@album.errors.count, "error") %> prohibited this Album from being saved:</h2> | |
<ul> | |
<% @album.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<div class="actions"> | |
<%= f.label "name" %> | |
<%= f.text_field :name %> | |
<h2>Songs:</h2> | |
<div id="songs"> | |
<%= f.simple_fields_for :songs do |event| %> | |
<%= render 'song_fields', :f=>event %> | |
<% end %> | |
<div class="links"> | |
<%= link_to_add_association 'add event', f, :songs %> | |
</div> | |
</div> | |
<%= f.submit "#{@album.new_record? ? 'Create' : 'Update'} Album" %> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment