Skip to content

Commit

Permalink
Doubly-nested forms blueprints do not have ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
jksilliman committed Jun 26, 2011
1 parent 09d6eb9 commit f020a23
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/nested_form/builder.rb
Expand Up @@ -19,12 +19,14 @@ def link_to_add(*args, &block)
args << (options.delete(:href) || "javascript:void(0)")
args << options
@fields ||= {}
@template.after_nested_form(association) do
model_object = object.class.reflect_on_association(association).klass.new
output = %Q[<div id="#{association}_fields_blueprint" style="display: none">].html_safe
output << fields_for(association, model_object, :child_index => "new_#{association}", &@fields[association])
output.safe_concat('</div>')
output
if object.persisted?
@template.after_nested_form(association) do
model_object = object.class.reflect_on_association(association).klass.new
output = %Q[<div id="#{association}_fields_blueprint" style="display: none">].html_safe
output << fields_for(association, model_object, :child_index => "new_#{association}", &@fields[association])
output.safe_concat('</div>')
output
end
end
@template.link_to(*args, &block)
end
Expand Down

0 comments on commit f020a23

Please sign in to comment.