Module: SimpleNestedForm::ViewHelper

Included in:
ActionView::Base
Defined in:
lib/simple_nested_form/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#after_nested_form(association, &block) ⇒ Object



13
14
15
16
17
18
# File 'lib/simple_nested_form/view_helper.rb', line 13

def after_nested_form(association, &block)
  unless form_associations.include? association
    form_associations << association 
    form_callbacks << block
  end
end

#nested_form_for(*args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/simple_nested_form/view_helper.rb', line 3

def nested_form_for(*args, &block)
  options = args.extract_options!.reverse_merge(:builder => SimpleNestedForm::Builder)

  simple_form_for(*(args << options), &block).tap do |output|
    form_callbacks.each do |callback|
      output << callback.call
    end
  end
end