2 つのフィールドがstart_time
ありend_time
、フォームを送信するときに更新したいと考えています。スライダーで動作させたいので、基本的に設定されたstart_time
最小ハンドルと最大ハンドルが設定されますend_time
https://github.com/glyph-fr/simple_form_extensionslider_input.rb
から持っています
class SliderInput < SimpleForm::Inputs::Base
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
end
そして、私の中では、_form.html.slim
このように見えます
=f.input_field :start_time, as: :slider
現在、フォームを送信した後、値がデータベースに保存されていません。また、start_time
とend_time
を 1 つの入力フィールドに接続して、レンジ スライダーを操作する方法はありますか?
ありがとう