Class: Trestle::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/trestle/form.rb,
lib/trestle/form/field.rb,
lib/trestle/form/fields.rb,
lib/trestle/form/builder.rb,
lib/trestle/form/renderer.rb,
lib/trestle/form/automatic.rb,
lib/trestle/form/fields/select.rb,
lib/trestle/form/fields/check_box.rb,
lib/trestle/form/fields/form_group.rb,
lib/trestle/form/fields/tag_select.rb,
lib/trestle/form/fields/date_select.rb,
lib/trestle/form/fields/range_field.rb,
lib/trestle/form/fields/time_select.rb,
lib/trestle/form/fields/form_control.rb,
lib/trestle/form/fields/radio_button.rb,
lib/trestle/form/fields/static_field.rb,
lib/trestle/form/fields/datetime_select.rb,
lib/trestle/form/fields/time_zone_select.rb,
lib/trestle/form/fields/check_box_helpers.rb,
lib/trestle/form/fields/collection_select.rb,
lib/trestle/form/fields/radio_button_helpers.rb,
lib/trestle/form/fields/collection_check_boxes.rb,
lib/trestle/form/fields/collection_radio_buttons.rb,
lib/trestle/form/fields/grouped_collection_select.rb

Direct Known Subclasses

Automatic

Defined Under Namespace

Modules: Fields Classes: Automatic, Builder, Field, Renderer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Form

Returns a new instance of Form.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/trestle/form.rb', line 11

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



9
10
11
# File 'lib/trestle/form.rb', line 9

def block
  @block
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/trestle/form.rb', line 9

def options
  @options
end

Instance Method Details

#dialog?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/trestle/form.rb', line 29

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

#modal?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/trestle/form.rb', line 25

def modal?
  options[:modal]
end

#render(template, instance) ⇒ Object



34
35
36
# File 'lib/trestle/form.rb', line 34

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