Sha256: 4f655dfc7486382a5b400991222df2a4cd1d5ef0237e020567d9e0cf252456ec

Contents?: true

Size: 537 Bytes

Versions: 4

Compression:

Stored size: 537 Bytes

Contents

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

    super
  end

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

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

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

  def controller
    "datepicker"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/trestle/form/fields/date_picker.rb
trestle-0.10.0 lib/trestle/form/fields/date_picker.rb
trestle-0.10.0.pre2 lib/trestle/form/fields/date_picker.rb
trestle-0.10.0.pre lib/trestle/form/fields/date_picker.rb