Class: Inputs::EffectiveDateTimePicker::Input

Inherits:
Effective::FormInput show all
Defined in:
app/models/inputs/effective_date_time_picker/input.rb

Instance Method Summary collapse

Methods inherited from Effective::FormInput

#field_name, #initialize, #js_options, #options, #value

Constructor Details

This class inherits a constructor from Effective::FormInput

Instance Method Details

#default_input_htmlObject



10
11
12
# File 'app/models/inputs/effective_date_time_picker/input.rb', line 10

def default_input_html
  {class: 'effective_date_time_picker datetime'}
end

#default_input_jsObject



6
7
8
# File 'app/models/inputs/effective_date_time_picker/input.rb', line 6

def default_input_js
  {format: 'YYYY-MM-DD HH:mm', sideBySide: true}
end

#html_optionsObject



27
28
29
30
31
32
33
# File 'app/models/inputs/effective_date_time_picker/input.rb', line 27

def html_options
  super.tap do |html_options|
    if js_options[:format] == default_input_js[:format] # Unless someone changed from the default
      html_options[:pattern] = '\d{4}(-\d{2})?-(\d{2})?( \d+)?(:\d{2})?' # Match default pattern defined above
    end
  end
end

#to_htmlObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/inputs/effective_date_time_picker/input.rb', line 14

def to_html
  if options[:input_group] == false
    return text_field_tag(field_name, value, tag_options)
  end

  (:div, class: 'input-group') do
    (:span, class: 'input-group-addon') do
      (:i, '', class: 'glyphicon glyphicon-calendar').html_safe
    end +
    text_field_tag(field_name, value, tag_options)
  end
end