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

#default_iconObject


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

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

#enable_date_picker?Boolean

Returns:

  • (Boolean)

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

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

#normalize_options!Object


2
3
4
5
6
7
8
9
10
11
12
# 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

  if enable_date_picker?
    options.reverse_merge!(data: { picker: true, allow_clear: true })
  end

  super
end