Class: SliderInput
- Inherits:
-
Formtastic::Inputs::StringInput
- Object
- Formtastic::Inputs::StringInput
- SliderInput
- Includes:
- ActionView::Context, ActionView::Helpers, FormSlider::Helper
- Defined in:
- app/inputs/slider_input.rb
Overview
custom input for formtastic can be used like this:
f.input :score, as: :slider, min: 1, max: 5
Instance Method Summary collapse
Methods included from FormSlider::Helper
#slider_label, #slider_options
Instance Method Details
#to_html ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/inputs/slider_input.rb', line 11 def to_html value = object.send(method) || [:min] label = (method, ) = content_tag :div, '', (method, ) output = builder.input(method, .merge(input_html: { value: value }, wrapper_html: { class: "slider-container" })) output.gsub! /(<label).*(<\/label>)/, label output.insert output.index(/(<input)/), output.html_safe end |