Skip to content

Commit

Permalink
Merge remote-tracking branch 'tomchentw/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Padilla committed Aug 29, 2012
2 parents 41251ea + f60037d commit 8ede806
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rails3-jquery-autocomplete/simple_form_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class AutocompleteCollectionInput < CollectionInput
include Autocomplete

def input
# http://www.codeofficer.com/blog/entry/form_builders_in_rails_discovering_field_names_and_ids_for_javascript/
hidden_id = "#{object_name}_#{attribute_name}_hidden".gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
id_element = options[:id_element]
if id_element
id_element << ", ##{object_name}_#{attribute_name}[type=hidden]"
id_element << ", #" << hidden_id
else
id_element = "##{object_name}_#{attribute_name}[type=hidden]"
id_element = "#" + hidden_id
end
options[:id_element] = id_element
autocomplete_options = rewrite_autocomplete_option
Expand All @@ -64,6 +66,7 @@ def input
else
input_html_options
end
hidden_options[:id] = hidden_id
out << @builder.hidden_field(
attribute_name,
hidden_options
Expand Down

0 comments on commit 8ede806

Please sign in to comment.