Module: Trestle::Form::Fields::DatePicker

Included in:
DateField, DatetimeField, TimeField
Defined in:
lib/trestle/form/fields/date_picker.rb

Instance Method Summary collapse

Instance Method Details

#controllerObject



24
25
26
# File 'lib/trestle/form/fields/date_picker.rb', line 24

def controller
  "datepicker"
end

#default_iconObject



16
17
18
# File 'lib/trestle/form/fields/date_picker.rb', line 16

def default_icon
  icon("fa fa-calendar")
end

#defaultsObject



10
11
12
13
14
# File 'lib/trestle/form/fields/date_picker.rb', line 10

def defaults
  defaults = super
  defaults.merge!(data: { controller: controller, allow_clear: true }) if enable_date_picker?
  defaults
end

#enable_date_picker?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/trestle/form/fields/date_picker.rb', line 20

def enable_date_picker?
  !disabled? && !readonly? && options[:picker] != false
end

#normalize_options!Object



2
3
4
5
6
7
8
# File 'lib/trestle/form/fields/date_picker.rb', line 2

def normalize_options!
  unless options[:prepend] == false
    options[:prepend] ||= options.delete(:icon) { default_icon }
  end

  super
end