Class: VideoPickerInput

Inherits:
TomSelectInput
  • Object
show all
Defined in:
app/inputs/video_picker_input.rb

Overview

Tom Select video picker with async server-side loading
Use as: :video_picker in forms

Example:
<%= f.input :quote_builder_video_id, as: :video_picker,
placeholder: '(Inherit from parent)',
hint: 'Select a video for the quote builder' %>

Instance Method Summary collapse

Methods inherited from TomSelectInput

#input_html_classes

Instance Method Details

#collectionObject



21
22
23
24
25
# File 'app/inputs/video_picker_input.rb', line 21

def collection
  return [] unless selected_value

  Video.where(id: selected_value).map { |v| [v.title, v.id] }
end

#input(wrapper_options = nil) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/inputs/video_picker_input.rb', line 12

def input(wrapper_options = nil)
  input_html_options[:data] ||= {}
  input_html_options[:data]['tom-select-suggest-url-value'] = template.lookup_videos_path
  input_html_options[:data]['tom-select-min-chars-value'] = 0
  input_html_options[:data]['tom-select-preload-value'] = true

  super
end