Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form example <SettingsForm data={data.form} /> wrong use <SettingsForm {data} /> #1630

Open
good-dev-student opened this issue Jan 17, 2025 · 1 comment
Labels
type: documentation A change or addition to the documentation

Comments

@good-dev-student
Copy link

Change Type

Correction

Proposed Changes

Hi simple replace the :

<SettingsForm data={data.form} />

with

<SettingsForm {data} />

Why TR;TL

if you apply the docs will have this issue :

Property 'form' is missing in type 'SuperValidated<{ username: string; }, any, { username: string; }>' but required in type '{ form: SuperValidated<{ username: string; }>; }'.ts(2741)

in src\routes\settings+page.svelte

<script lang="ts">
	import SettingsForm from './settings-form.svelte';
	let { data } = $props();
	console.log(data);

{
  form: {
    id: '16btw7k',
    valid: false,
    posted: false,
    errors: {},
    data: { username: '' },
    constraints: { username: [Object] }
  }
}
	
</script>

<SettingsForm data={data.form} />

so if you pass the form then in the component src\routes\settings\settings-form.svelte YOU USE - > data.form

 const form = superForm(data.form, {
     validators: zodClient(formSchema),
    });

you will face this issue:

SuperFormError: No form data sent to superForm. Make sure the output from superValidate is used (usually data.form) and that it's not null or undefined. Alternatively, an object with default values for the form can also be used, but then constraints won't be available.
@good-dev-student good-dev-student added the type: documentation A change or addition to the documentation label Jan 17, 2025
@ieedan
Copy link
Contributor

ieedan commented Jan 17, 2025

Which example is this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A change or addition to the documentation
Projects
None yet
Development

No branches or pull requests

2 participants