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
@razvn I think the problem is that you haven't read the example the whole way though. If you paste the client side code from the example straight into a page it won't work because it is meant to be a component.
To fix this you should use that code in a component as intended or adapt it by changing the code like so:
<script lang="ts">
import * as Form from '$lib/components/ui/form/index.js';
import { Input } from '$lib/components/ui/input/index.js';
import { formSchema, type FormSchema } from './schema';
import { superForm } from 'sveltekit-superforms';
import { zodClient } from 'sveltekit-superforms/adapters';
+ let { data } = $props();- export let data: SuperValidated<Infer<FormSchema>>;+ const form = superForm(data.form, {- const form = superForm(data, {
validators: zodClient(formSchema)
});
const { form: formData, enhance } = form;
</script>
<form method="POST" use:enhance>
<Form.Field {form} name="username">
<Form.Control>
{#snippet children({ props })}
<Form.Label>Username</Form.Label>
<Input {...props} bind:value={$formData.username} />
{/snippet}
</Form.Control>
<Form.Description>This is your public display name.</Form.Description>
<Form.FieldErrors />
</Form.Field>
<Form.Button>Submit</Form.Button>
</form>
Repository owner
locked and limited conversation to collaborators
Dec 13, 2024
Change Type
Addition
Proposed Changes
I tried this exemple and got an error... with Svelte 5.
Turns out it needs:
dataType: 'json'
to work:The text was updated successfully, but these errors were encountered: