Sha256: 5bcca25ee6332c91bbfdcd725cb55076764a72079c41a9a48fa87b02061dabc6

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

module NestedForm
  module ViewHelper
    def nested_form_for(*args, &block)
      options = args.extract_options!.reverse_merge(:builder => NestedForm::Builder)
      output = form_for(*(args << options), &block)
      @after_nested_form_callbacks ||= []
      fields = @after_nested_form_callbacks.map do |callback|
        callback.call
      end
      output << fields.join(" ").html_safe
    end
    
    def after_nested_form(association, &block)
      @associations ||= []
      @after_nested_form_callbacks ||= []
      unless @associations.include?(association)
        @associations << association 
        @after_nested_form_callbacks << block
      end
    end
  end
end

class ActionView::Base
  include NestedForm::ViewHelper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nested_form-0.0.0 lib/nested_form/view_helper.rb