Module: AutocompleteSelect::Helper

Defined in:
lib/autocomplete_select/helper.rb

Instance Method Summary collapse

Instance Method Details

#autocomplete_select_options(path, label_or_options = nil, args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/autocomplete_select/helper.rb', line 3

def autocomplete_select_options(path, label_or_options = nil, args)
  if label_or_options.is_a?(Hash)
    options = label_or_options
  else
    label = label_or_options
    options = args.shift
  end
  html_options = args.shift || {}

  options ||= {}
  options[:source] = path
  options[:label] = label if label
  html_options.deep_merge({
    :data => {
      :"autocomplete-select" => options.to_json
    }
  })
end

#autocomplete_select_tag(name, path, value = nil, label_or_options = nil, *args) ⇒ Object



22
23
24
# File 'lib/autocomplete_select/helper.rb', line 22

def autocomplete_select_tag(name, path, value = nil, label_or_options = nil, *args)
  text_field_tag(name, value, autocomplete_select_options(path, label_or_options, args))
end