Class: StorePickerTomSelectInput
- Inherits:
-
TomSelectInput
- Object
- SimpleForm::Inputs::CollectionSelectInput
- TomSelectInput
- StorePickerTomSelectInput
- Defined in:
- app/inputs/store_picker_tom_select_input.rb
Overview
Tom Select version of StorePickerInput
Use as: :store_picker_tom_select instead of :store_picker
Supports remote search via /stores/lookup endpoint
Pass company_id via query_params to filter by company
Instance Method Summary collapse
Methods inherited from TomSelectInput
Instance Method Details
#collection ⇒ Object
16 17 18 19 20 |
# File 'app/inputs/store_picker_tom_select_input.rb', line 16 def collection return [] unless selected_value Store.where(id: selected_value).map { |s| [s.name, s.id] } end |
#input(wrapper_options = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/inputs/store_picker_tom_select_input.rb', line 6 def input( = nil) [:data] ||= {} query_params = [:query_params] || [:query_params] || {} [:data]['tom-select-suggest-url-value'] = template.lookup_stores_path(query_params) [:data]['tom-select-min-chars-value'] = 0 [:data]['tom-select-preload-value'] = true super end |