pstanoev / simple-svelte-autocomplete

Simple Autocomplete / typeahead component for Svelte
http://simple-svelte-autocomplete.surge.sh/
MIT License
464 stars 78 forks source link

Problem passing values to Sveltekit form actions #209

Open miklereverie opened 1 year ago

miklereverie commented 1 year ago

Hello! First of all, thank you for this amazing component!

I'm having a bit of trouble passing the values from the autocomplete (with multiple enabled, an array of objects) to a form action using Sveltekit. For some reason, I only get an empty array.

I've created a reproduction of the issue in this SvelteLab REPL: https://www.sveltelab.dev/5k0yutjgm1cqa3z

Check out the devtools console once you submit the form, you'll see the output from line 34 is an empty array, despite having the log from line 32 which outputs the value of the selected items (which are binded to a variable, like the example provided in the docs). I'm thinking maybe the autocomplete doesn't store formData? how would I go about passing the values to a form action in page.server.ts?

Am I doing something wrong?

Thanks in advance for your time and your help!