Class: SimpleFormExtension::Inputs::DateTimeInput

Inherits:
SimpleForm::Inputs::DateTimeInput
  • Object
show all
Includes:
Translations
Defined in:
lib/simple_form_extension/inputs/date_time_input.rb

Instance Method Summary collapse

Methods included from Translations

#_translate

Instance Method Details

#input(wrapper_options = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/simple_form_extension/inputs/date_time_input.rb', line 8

def input(wrapper_options = nil)
	input_html_options[:class] << "form-control"

  input_html_options[:data] ||= {}
  input_html_options[:data].merge!(type_specific_option)

  if (value = object.send(attribute_name).presence) && !input_html_options.key?(:value)
    format = _translate("#{ input_type }.format.rails")
    input_html_options[:value] = I18n.l(value, format: format)
  end

  (:div, class: 'input-group') do
    @builder.text_field(attribute_name, input_html_options) +

    (:span, class: 'input-group-btn') do
      (:button, type: 'button', class: 'btn btn-default datetimepicker-trigger') do
        (:i, '', class: "fa fa-#{ icon }")
      end
    end
  end
end