Class: Trestle::Form::Fields::TimeZoneSelect

Inherits:
Trestle::Form::Field show all
Defined in:
lib/trestle/form/fields/time_zone_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, priority_zones = nil, options = {}, html_options = {}, &block) ⇒ TimeZoneSelect

Returns a new instance of TimeZoneSelect.



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

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

  @priority_zones = priority_zones
  @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_zone_select.rb', line 5

def html_options
  @html_options
end

#priority_zonesObject (readonly)

Returns the value of attribute priority_zones.



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

def priority_zones
  @priority_zones
end

Instance Method Details

#default_html_optionsObject



18
19
20
# File 'lib/trestle/form/fields/time_zone_select.rb', line 18

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

#fieldObject



14
15
16
# File 'lib/trestle/form/fields/time_zone_select.rb', line 14

def field
  builder.raw_time_zone_select(name, priority_zones, options, html_options, &block)
end