Module: ActiveAdmin::SearchableSelect::SelectInputExtension
- Defined in:
- lib/activeadmin/searchable_select/select_input_extension.rb
Overview
Mixin for searchable select inputs.
Supports the same options as inputs of type :select
.
Adds support for an ajax
option to fetch options data from a
JSON endpoint. Pass either true
to use defaults or a hash
containing some of the following options:
resource
: ActiveRecord model class of ActiveAdmin resource which provides the collection action to fetch options from. By default the resource is auto detected via the name of the input attribute.collection_name
: Name passed to thesearchable_select_options
method that defines the collection action to fetch options from.params
: Hash of query parameters that shall be passed to the options endpoint.path_params
: Hash of parameters, which would be passed to the dynamic collection path generation for the resource. e.gadmin_articles_path(path_params)
If the ajax
option is present, the collection
option is
ignored.
Instance Method Summary collapse
- #collection_from_options ⇒ Object private
- #input_html_options ⇒ Object private
Instance Method Details
#collection_from_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 |
# File 'lib/activeadmin/searchable_select/select_input_extension.rb', line 38 def return super unless [:ajax] if SearchableSelect. else selected_value_collection end end |
#input_html_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 |
# File 'lib/activeadmin/searchable_select/select_input_extension.rb', line 31 def = super [:class] = [[:class], 'searchable-select-input'].compact.join(' ') .merge('data-ajax-url' => ajax_url) end |