rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.27k stars 180 forks source link

Selected options in a form with form.get() #386

Closed blazzjosh closed 2 years ago

blazzjosh commented 2 years ago

How would you get the selected values in a form? https://svelte.dev/repl/e8ed0807a36b45898568a27824b1db72?version=3.46.4

rob-balfre commented 2 years ago

Use on:submit instead of action + formData.

Svelte-select isn't a HTML form element so treating it like a normal <select> won't work.

https://svelte.dev/repl/16778e290bf548f790dc45d249bed94d?version=3.46.4

michapixel commented 2 years ago

sorry to bother: but i actually have this

<Select  
    bind:value={dealer} 
    name="dealer"
    id="dealer" 
    value={testInput.dealer}
    items={dealers} 
>
</Select>

but compiler always nags:

ParseError: Attributes need to be unique
src/partials/sections/Mitmachen.section.svelte
173:                            name="dealer"
174:               id="dealer"
175:                            value={testInput.dealer}
                  ^

so the problem is: setting the value and binding it to a var is not possible?