Module: SimpleForm::Inputs::Autocomplete

Included in:
AutocompleteCollectionInput, AutocompleteInput
Defined in:
lib/rails-autocomplete/simple_form_plugin.rb

Instance Method Summary collapse

Instance Method Details

#rewrite_autocomplete_optionObject

Method used to rename the autocomplete key to a more standard data-autocomplete key



8
9
10
11
12
13
14
# File 'lib/rails-autocomplete/simple_form_plugin.rb', line 8

def rewrite_autocomplete_option
  new_options = {}
  new_options["data-autocomplete-fields"] = JSON.generate(options.delete :fields) if options[:fields]
  new_options["data-update-elements"] = JSON.generate(options.delete :update_elements) if options[:update_elements]
  new_options["data-id-element"] = options.delete :id_element if options[:id_element]
  input_html_options.merge new_options
end