Class: Formtastic::Inputs::UiDatePickerInput

Inherits:
StringInput
  • Object
show all
Defined in:
lib/formtastic/inputs/ui_date_picker_input.rb

Direct Known Subclasses

UiDateTimePickerInput

Instance Method Summary collapse

Instance Method Details

#css_classObject



20
21
22
# File 'lib/formtastic/inputs/ui_date_picker_input.rb', line 20

def css_class
  "ui-date-picker"
end

#formatObject



12
13
14
# File 'lib/formtastic/inputs/ui_date_picker_input.rb', line 12

def format
  input_options[:format] || '%d %b %Y'
end

#input_html_optionsObject



24
25
26
27
# File 'lib/formtastic/inputs/ui_date_picker_input.rb', line 24

def input_html_options
  new_class = [super[:class], css_class].compact.join(" ")
  super.update(:class => new_class, :value => localized(value))
end

#localized(value) ⇒ Object



29
30
31
# File 'lib/formtastic/inputs/ui_date_picker_input.rb', line 29

def localized value
  value.nil? ? nil : I18n.localize(object.send(method))
end

#to_htmlObject



5
6
7
8
9
10
# File 'lib/formtastic/inputs/ui_date_picker_input.rb', line 5

def to_html
  input_wrapping do
    label_html <<
      builder.text_field(input_name, input_html_options)
  end
end

#valueObject



16
17
18
# File 'lib/formtastic/inputs/ui_date_picker_input.rb', line 16

def value
  input_options[:value] || object.send(method).try(:strftime, format)
end