Class: Trestle::Form::Fields::DateSelect

Inherits:
Trestle::Form::Field show all
Defined in:
lib/trestle/form/fields/date_select.rb

Instance Attribute Summary collapse

Attributes inherited from Trestle::Form::Field

#block, #builder, #name, #options, #template

Instance Method Summary collapse

Methods inherited from Trestle::Form::Field

#defaults, #disabled?, #errors, #form_group, #normalize_options!, #readonly?, #render

Constructor Details

#initialize(builder, template, name, options = {}, html_options = {}, &block) ⇒ DateSelect

Returns a new instance of DateSelect.



7
8
9
10
11
# File 'lib/trestle/form/fields/date_select.rb', line 7

def initialize(builder, template, name, options={}, html_options={}, &block)
  super(builder, template, name, options, &block)

  @html_options = default_html_options.merge(html_options)
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



5
6
7
# File 'lib/trestle/form/fields/date_select.rb', line 5

def html_options
  @html_options
end

Instance Method Details

#default_html_optionsObject



19
20
21
# File 'lib/trestle/form/fields/date_select.rb', line 19

def default_html_options
  Trestle::Options.new(class: ["form-select"], disabled: readonly?, data: { controller: "select" })
end

#fieldObject



13
14
15
16
17
# File 'lib/trestle/form/fields/date_select.rb', line 13

def field
  tag.div(class: "date-select") do
    builder.raw_date_select(name, options, html_options, &block)
  end
end