Search code examples
jquery-uiformtastic

Autocomplete for Formtastic


I have been looking at a way to add autocomplete functionality to a formtastic form and came across the crowdint / rails3-jquery-autocomplete but I haven't be able to get the latest version(0.9.1) to work with formtastic (which is a known issue) and in the previous version id-element helper doesn't work so it's not possible to set the option value in a hidden field when submit the form. And another gem, formtastic_autocomplete by elandesign is outdated. So I am wondering if there any alternative methods I could use to get an (jquery-ui?) autocomplete field in a formtastic form. My models are such that product belongs to a brand and a brand has many products(there is a brand_id column ib the product table), so currently I have which means that automatically creates an option select for the association
Thanks, Alex


Solution

  • If you don't use a gem that tries to be smart and does everything for you, the fact that you are using formtastic is kind of irrelevant. The HTML generated by formastic is not different from the HTML generated using the regular form helpers.

    You can easily use the jquery ui autocomplete plugin.