You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off I love the library, and it's helped my get a handle of my forms. With that in mind I have a suggestion.
Is your feature request related to a problem? Please describe.
Now that Svelte 5 Runes are a thing I'm not enjoying working with the SuperFormData store. I end up defining the super form, then setting a separate variable for the form data store itself so I can subscribe to it using bind:value on an input. As far as I can tell Svelte doesn't support subscribing to a property of an object. This really isn't a problem if there's only on form on a page, but let's be honest, that rarely happens. Most pages have 2 or more pages, and with a 5 to 10 pages like this things get crazy fast.
This would be a basic form that I would define
<scriptlang="ts">
importSuperDebug, { superForm } from'sveltekit-superforms';importtype { PageData } from'./$types';import { valibotClient } from'sveltekit-superforms/adapters';import*asFormfrom'$lib/components/ui/form';import { Input } from'$shadcn/input';import { Button } from'$shadcn/button';import*asvfrom'valibot';let { data }: { data:PageData } =$props();/* Defined somewhere the client and server can see it */const testVali =v.object({ firstName: v.pipe(v.string()), lastName: v.pipe(v.string()) });const testForm =superForm(data.testForm, { validators: valibotClient(testVali) });const testFormData =testForm.form;
</script>
<SuperDebugdata={$testFormData} />
<formmethod="post"use:testForm.enhance>
<inputname="firstName"bind:value={$testFormData.firstName} />
<inputname="lastName"bind:value={$testFormData.lastName} />
<buttontype="submit">Submit this here form</button>
</form>
Describe the solution you'd like
What I would like to see is a self contained class that can be built and extended with the form data as a Rune, so no $ subscribe is needed. Extending this class would be helpful for a form that is inside of a modal or sheet. The open property could be set of the new class, and keep everything self contained.
I'd like to see an implementation similar to this.
<scriptlang="ts">
importSuperDebugfrom'sveltekit-superforms';importtype { PageData } from'./$types';import { valibotClient } from'sveltekit-superforms/adapters';import*asFormfrom'$lib/components/ui/form';import { Input } from'$shadcn/input';import { Button } from'$shadcn/button';import*asvfrom'valibot';let { data }: { data:PageData } =$props();/* Defined somewhere the client and server can see it */const testVali =v.object({ firstName: v.pipe(v.string()), lastName: v.pipe(v.string()) });const testForm =SuperForm(data.testForm, { validators: valibotClient(testVali) });
</script>
<SuperDebugdata={testForm.data} />
<formmethod="post"use:testForm.enhance>
<inputname="firstName"bind:value={testForm.data.firstName} />
<inputname="lastName"bind:value={testForm.data.lastName} />
<buttontype="submit">Submit this here form</button>
</form>
Describe alternatives you've considered
I've tried building a class myself, but I keep running into the stores being an issue to subscribe to. I'm sure there's a somewhat simple way around it, but it seems like the idea I laid out would be helpful for others as well.
The text was updated successfully, but these errors were encountered:
@trancikk I'm not 100% percent sure what you mean by WA. I'd be interested in your solution though. I've tried wrapping the store in a $state rune, but without much success.
First off I love the library, and it's helped my get a handle of my forms. With that in mind I have a suggestion.
Is your feature request related to a problem? Please describe.
Now that Svelte 5 Runes are a thing I'm not enjoying working with the SuperFormData store. I end up defining the super form, then setting a separate variable for the form data store itself so I can subscribe to it using bind:value on an input. As far as I can tell Svelte doesn't support subscribing to a property of an object. This really isn't a problem if there's only on form on a page, but let's be honest, that rarely happens. Most pages have 2 or more pages, and with a 5 to 10 pages like this things get crazy fast.
This would be a basic form that I would define
Describe the solution you'd like
What I would like to see is a self contained class that can be built and extended with the form data as a Rune, so no $ subscribe is needed. Extending this class would be helpful for a form that is inside of a modal or sheet. The open property could be set of the new class, and keep everything self contained.
I'd like to see an implementation similar to this.
Describe alternatives you've considered
I've tried building a class myself, but I keep running into the stores being an issue to subscribe to. I'm sure there's a somewhat simple way around it, but it seems like the idea I laid out would be helpful for others as well.
The text was updated successfully, but these errors were encountered: