Class: DatetimePickerInput
- Inherits:
-
SimpleForm::Inputs::StringInput
- Object
- SimpleForm::Inputs::StringInput
- DatetimePickerInput
- Defined in:
- app/inputs/datetime_picker_input.rb
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
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/inputs/datetime_picker_input.rb', line 2 def input() floating = .fetch(:floating, false) dt_val = object.try(attribute_name).try(:strftime, '%Y-%m-%dT%H:%M') [:type] = :'datetime-local' [:html5] = true [:value] = dt_val [:'data-input'] = '' [:class] = [[:class], 'pe-5'].compact.join(' ') if floating # Bootstrap floating labels require a non-absent placeholder so the # :not(:placeholder-shown) CSS selector fires and floats the label up. [:placeholder] ||= ' ' template.content_tag(:div, class: 'form-floating datetime_picker_wrapper date-picker_wrapper_single') 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') 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.
31 32 33 34 35 |
# File 'app/inputs/datetime_picker_input.rb', line 31 def label( = nil) return ''.html_safe if .fetch(:floating, false) super end |