Module: BootstrapFormExtensions::DateTimePickers

Includes:
Helpers
Defined in:
lib/bootstrap_form_extensions/date_time_pickers.rb

Instance Method Summary collapse

Methods included from Helpers

#glyphicon_tag, #merge_css_classes, #true?

Instance Method Details

#date_picker(method, **options) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/bootstrap_form_extensions/date_time_pickers.rb', line 27

def date_picker method, **options
  # TODO: Replace for these commented out lines, once this pull request is merged: https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/238
  # options[:wrapper] ||= {}
  # options[:wrapper].merge! inline: true
  options[:control_col] = control_col_for_date_time_pickers options
  form_group_builder(method, options) { date_picker_builder method, options }
end

#date_time_picker(attribute, **options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bootstrap_form_extensions/date_time_pickers.rb', line 7

def date_time_picker attribute, **options
  name = attribute.to_s.sub /_at$/, ''
  date_method  = options.delete(:date_method) { "#{name}_date".to_sym }
  time_method  = options.delete(:time_method) { "#{name}_time".to_sym }

  date_options = options.delete(:date_options) { {} }
  time_options = options.delete(:time_options) { {} }
  date_options[:class] = merge_css_classes 'form-control', date_options[:class]
  time_options[:class] = merge_css_classes 'form-control', time_options[:class]

  # TODO: Replace for these commented out lines, once this pull request is merged: https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/238
  # options[:wrapper] ||= {}
  # options[:wrapper].merge! inline: true
  options[:control_col] = control_col_for_date_time_pickers options

  date_picker_html =  :div, date_picker_builder(date_method, date_options), class: 'form-group'
  time_picker_html =  :div, time_picker_builder(time_method, time_options), class: 'form-group'
  form_group_builder(attribute, options) { date_picker_html + '  '.html_safe + time_picker_html }
end

#time_picker(method, **options) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/bootstrap_form_extensions/date_time_pickers.rb', line 35

def time_picker method, **options
  # TODO: Replace for these commented out lines, once this pull request is merged: https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/238
  # options[:wrapper] ||= {}
  # options[:wrapper].merge! inline: true
  options[:control_col] = control_col_for_date_time_pickers options
  form_group_builder(method, options) { time_picker_builder method, options }
end