Module: StimulusPlumbers::Form::Fields::Inputs::Datetime

Included in:
Builder
Defined in:
lib/stimulus_plumbers/form/fields/inputs/datetime.rb

Instance Method Summary collapse

Instance Method Details

#date_field(attribute, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stimulus_plumbers/form/fields/inputs/datetime.rb', line 8

def date_field(attribute, options = {})
  html_native = options.delete(:html_native) { false }
  Field.new(@template, **options).render(
    object,
    attribute,
    input_id: field_id(attribute)
  ) do |html_opts, opts, error|
    if html_native
      html_options = merge_html_options(opts, html_opts, field_theme(:form_input, error: error))
      super(attribute, html_options)
    else
      render_date_combobox(attribute, html_opts, error)
    end
  end
end

#time_field(attribute, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/stimulus_plumbers/form/fields/inputs/datetime.rb', line 24

def time_field(attribute, options = {})
  html_native = options.delete(:html_native) { false }
  format      = options.delete(:format) { :h12 }
  step        = options.delete(:step) { 1 }
  Field.new(@template, **options).render(
    object,
    attribute,
    input_id: field_id(attribute)
  ) do |html_opts, opts, error|
    if html_native
      html_options = merge_html_options(opts, html_opts, field_theme(:form_input, error: error))
      super(attribute, html_options)
    else
      render_time_combobox(attribute, html_opts, error, format: format, step: step)
    end
  end
end