Class: SimpleFormExtension::Inputs::SliderInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
lib/simple_form_extension/inputs/slider_input.rb

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options = nil) ⇒ 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
# File 'lib/simple_form_extension/inputs/slider_input.rb', line 4

def input(wrapper_options = nil)
  input_html_options[:class] << 'form-control'

  input_html_options[:data] ||= {}
  input_html_options[:data][:'simple-form-slider'] = true

  [:min, :max, :step, :orientation, :range, :value].each do |key|
    if options.key?(key)
      input_html_options[:data][:"slider-#{ key }"] = options[key]
    end
  end

  input_html_options[:data][:'slider-value'] ||= object.send(attribute_name)

  if options[:disabled]
    input_html_options[:data][:'slider-enabled'] = false
  end

  if options[:ticks]
    input_html_options[:data][:ticks] = options[:ticks].to_json
  end

  @builder.hidden_field(attribute_name, input_html_options)
end