afcapel / stimulus-autocomplete

Stimulus autocomplete component
MIT License
478 stars 61 forks source link

Prefilled form #107

Closed zairigimad closed 2 years ago

zairigimad commented 2 years ago

I’m trying to use the autocomplete to get list of items lproducts to prefill a form. For example i serach for product 1. I want to get his id name price to prefill the form.

is there a way to achieve this with the component ?

afcapel commented 2 years ago

Not sure I understand exactly what you're trying to achieve but the autocomplete itself won't fill in other fields in a form. You can listen to autocomplete.change events and when the autocomplete changes use the new value to fetch other values and fill the form with them, but that's something you'll have to code yourself.