Class: DateTimePickerInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
app/inputs/date_time_picker_input.rb

Instance Method Summary collapse

Instance Method Details

#date_input_html_optionsObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/inputs/date_time_picker_input.rb', line 9

def date_input_html_options
  options = {
    id: "#{attribute_name}_date",
    class: 'form-control datepicker',
    name: "#{object_name}[#{attribute_name}_date]",
    readonly: true,
    style: 'margin-right: 10px; width: auto; display: inline-block;'
  }

  options[:value] = @builder.object[attribute_name].strftime("%B %e, %Y") unless @builder.object[attribute_name].nil?
  options
end

#input(wrapper_options) ⇒ Object



2
3
4
5
6
7
# File 'app/inputs/date_time_picker_input.rb', line 2

def input(wrapper_options)
  template.(:div, class: 'form-group date time form_datetime') do
    template.concat @builder.text_field(attribute_name, date_input_html_options)
    template.concat @builder.text_field(attribute_name, time_input_html_options)
  end
end

#time_input_html_optionsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/inputs/date_time_picker_input.rb', line 22

def time_input_html_options
  options = {
    id: "#{attribute_name}_time",
    class: 'form-control timepicker',
    name: "#{object_name}[#{attribute_name}_time]",
    readonly: true,
    style: 'width: auto; display: inline-block;'
  }

  if @builder.object[attribute_name].nil?
    options[:value] = "12:00 AM"
  else
    options[:value] = @builder.object[attribute_name].strftime("%I:%M %p")
  end

  options
end