Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Includes:
FormTagHelper, TagHelper
Defined in:
lib/rails_autocomplete/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#autocomplete_field(name, path) ⇒ Object



12
13
14
15
16
17
# File 'lib/rails_autocomplete/form_helper.rb', line 12

def autocomplete_field name, path
  hash = Digest::MD5.hexdigest(name.to_s)
  output = text_field_tag("#{name}_autocomplete", nil, {  "class" => "rails-autocomplete", "data-autocomplete-parent" => hash, "data-autocomplete-url" => path, "data-provide" => "typeahead", "data-source" => "rails_autocomplete", "autocomplete" => "off" }).html_safe
  output << self.hidden_field(name, { "data-autocomplete-child" => hash }).html_safe
  output
end