Class: Trestle::Form::Fields::TimeSelect

Inherits:
Trestle::Form::Field show all
Defined in:
lib/trestle/form/fields/time_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, #errors, #form_group, #normalize_options!, #readonly?, #render

Constructor Details

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

Returns a new instance of TimeSelect.



7
8
9
10
11
# File 'lib/trestle/form/fields/time_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/time_select.rb', line 5

def html_options
  @html_options
end

Instance Method Details

#default_html_optionsObject



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

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

#fieldObject



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

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