Skip to content

Commit ffe1a45

Browse files
committed
added documentation for using autocomplete to submit multiple values separated by a given delimiter
1 parent 4a4391f commit ffe1a45

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ If you are not using a FormBuilder (form_for) or you just want to include an aut
197197
autocomplete_field_tag 'address', '', address_autocomplete_path, :size => 75
198198
end
199199

200+
#### Autocomplete with Multiple Values Separated by Delimiter
201+
202+
To generate an autocomplete input field that accepts multiple values separated by a given delimiter, add the `'data-delimiter'` and `:multiple` options:
203+
204+
form_for @product do |f|
205+
f.autocomplete_field :brand_names, autocomplete_brand_name_products_path,
206+
'data-delimiter' => ',', :multiple => true
207+
end
208+
209+
NOTE: Setting the `:multiple` option to `true` will result in the chosen values being submitted as an array. Leaving this option off will result in the values being passed as a single string, with the values separated by your chosen delimiter.
210+
200211
Now your autocomplete code is unobtrusive, Rails 3 style.
201212

202213
### Getting the object id

0 commit comments

Comments
 (0)