Skip to content

Can't get Formsnap & Superforms to work #1028

Answered by gregmsanderson
malkinmag asked this question in Help
Discussion options

You must be logged in to vote

Hi,

I'm using the form component within an SPA. It works for me but it's hard to compare exactly since I don't have the server.ts page bit to compare. My guess would be that in the script in your page.svelte you perhaps instead need to have:

import { formSchema } from './schema';
import SuperDebug, { superForm } from 'sveltekit-superforms';
import { zodClient } from 'sveltekit-superforms/adapters';

export let data;

const form = superForm(data, {
   validators: zodClient(formSchema),
});
 
const { form: formData, errors, enhance } = form; // ... since this line then lets you access $formData ...

Having done that, you can now access $formData. Since based on that TypeError: Cannot read p…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@zvolsky
Comment options

Answer selected by malkinmag
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants