svelte-use-form icon indicating copy to clipboard operation
svelte-use-form copied to clipboard

Adds support for multiple values in Checkboxes and Selects

Open Marnes opened this issue 1 year ago • 4 comments

Checkboxes with the same name and Multiple selects are currently not supported. This adds support for both by setting the value to an array of strings if it detects it is a multiple element.

This also changes to use the value of the checkbox instead of "checked" when setting the value.

Marnes avatar Sep 15 '23 15:09 Marnes

@noahsalvi I've update my PR. Any unspecified controls will return string | string[] | undefined, and if you specify with { username: { multiple: true } the return type will be string[] and if multiple: false | undefined then the return type will be string

Marnes avatar Sep 17 '23 13:09 Marnes

Awesome, nice work on the PR! Since it is quite a significant change I will be going over it for the next few days. Do you know of any breaking changes this could cause? Furthermore are there any other points that I should pay special attention to?

noahsalvi avatar Sep 17 '23 14:09 noahsalvi

Only breaking change is that checkboxes now returns the value of the checkbox and checked if no value specified. Existing code should work as is, only difference is for multi values you should add multiple: true.

I am testing with my own project as I am making changes, so hopefully nothing breaks.

Marnes avatar Sep 17 '23 14:09 Marnes

Hey, I have been following and using this fork since it's an interesting concept that I thought I might use in my project.

I have run into an interesting situation however where a fresh array of checkboxes show as touched from the start of the page load. I was trying to setup a REPL to demo and play around but I couldn't get around to loading the branch.

Just thought to report it here.

Thanks!

paulocr avatar Oct 07 '23 16:10 paulocr