svelte-use-form
svelte-use-form copied to clipboard
Adds support for multiple values in Checkboxes and Selects
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.
@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
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?
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.
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!