Sha256: 7ff8f81abbd721e3f30c1abf54af3822f0c86fb1c2771e40f1b49adac476d395

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

module Trestle
  module FormHelper
    def trestle_form_for(instance, options={}, &block)
      options[:builder] ||= Form::Builder
      options[:as] ||= admin.admin_name.singularize

      form_for(instance, options) do |f|
        with_form(f) { yield f }
      end
    end

    def with_form(form)
      @_trestle_form = form
      yield form if block_given?
    ensure
      @_trestle_form = nil
    end

    def form
      @_trestle_form
    end

    def toolbar(name, &block)
      content_for(:"#{name}_toolbar", &block)
    end

    def sidebar(&block)
      content_for(:sidebar, &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trestle-0.8.5 app/helpers/trestle/form_helper.rb
trestle-0.8.4 app/helpers/trestle/form_helper.rb