Sha256: 5f0675f7bd6d69a513bafee51d3348c1dadb667b5bdecd799bb45e20d9dc4eed

Contents?: true

Size: 942 Bytes

Versions: 4

Compression:

Stored size: 942 Bytes

Contents

module Trestle
  class Form
    require_relative "form/automatic"
    require_relative "form/builder"
    require_relative "form/field"
    require_relative "form/fields"
    require_relative "form/renderer"

    attr_reader :options, :block

    def initialize(options={}, &block)
      @options, @block = options, block

      if @options[:modal] == true
        @options[:modal] = {}
      end

      if options[:dialog]
        Trestle.deprecator.warn("`form dialog: true` is deprecated. Please use `form modal: true` instead.", caller_locations(3))
        @options.delete(:dialog)
        @options[:modal] = {}
      end
    end

    def modal?
      options[:modal]
    end

    def dialog?
      Trestle.deprecator.warn("`Trestle::Form#dialog?` is deprecated. Please use `modal?` instead.")
      options[:modal]
    end

    def render(template, instance)
      Renderer.new(template).render_form(instance, &block)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/trestle/form.rb
trestle-0.10.0 lib/trestle/form.rb
trestle-0.10.0.pre2 lib/trestle/form.rb
trestle-0.10.0.pre lib/trestle/form.rb