Class: DatetimePickerInput
- Inherits:
-
SimpleForm::Inputs::StringInput
- Object
- SimpleForm::Inputs::StringInput
- DatetimePickerInput
- Defined in:
- app/inputs/datetime_picker_input.rb
Overview
SimpleForm input wrapper: datetime picker.
Instance Method Summary collapse
- #input(wrapper_options) ⇒ Object
-
#label(_wrapper_options = nil) ⇒ Object
In floating mode we render the label ourselves inside the wrapper (after the input, as Bootstrap requires).
Instance Method Details
#input(wrapper_options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/inputs/datetime_picker_input.rb', line 4 def input() floating = .fetch(:floating, false) [:type] = :text [:placeholder] ||= 'MM/DD/YYYY HH:MM' [:'data-input'] = '' [:class] = [[:class], 'pe-5'].compact.join(' ') style_css = .delete(:style) controller_data = { controller: 'date-picker', 'date-picker-enable-time-value': true, 'date-picker-format-value': 'Y-m-d H:i', 'date-picker-alt-format-value': 'm/d/Y h:i K' } if floating [:placeholder] ||= ' ' [:class] = [[:class], 'form-control'].compact.join(' ') template.content_tag(:div, class: 'form-floating datetime_picker_wrapper date-picker_wrapper_single', style: style_css, data: controller_data) do template.concat super() template.concat floating_label_tag template.concat clear_btn end else template.content_tag(:div, class: 'datetime_picker_wrapper date-picker_wrapper_single d-flex align-items-center position-relative', style: style_css, data: controller_data) do template.concat super() template.concat clear_btn end end end |
#label(_wrapper_options = nil) ⇒ Object
In floating mode we render the label ourselves inside the wrapper (after the
input, as Bootstrap requires). Suppress SimpleForm's external label only then.
38 39 40 41 42 |
# File 'app/inputs/datetime_picker_input.rb', line 38 def label( = nil) return ''.html_safe if .fetch(:floating, false) super end |