huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://shadcn-svelte.com
MIT License
4.89k stars 303 forks source link

Forms not working using Svelte 5 and Sveltekit 2 #564

Closed jramiroz98 closed 8 months ago

jramiroz98 commented 8 months ago

Current Behavior

I implement forms exactly as they are shown in the website and get the following error:

Form data sent directly to superForm instead of through superValidate. No initial data validation is made. Also, no constraints will exist for the form. Set the warnings.noValidationAndConstraints option to false to disable this warning.

Expected Behavior

Input field and submit button should be displayed, but instead I get error 500

Steps To Reproduce

  1. Build a new project using Shadcn
  2. Copy every step from the Forms implementation
  3. Run the server

Link to Reproduction / Stackblitz (reproduction template)

No response

More Information

It kind of worked once, reloaded and never again worked

wa-hab commented 8 months ago

Having the same issue, I managed to get rid of this error by calling await on superValidate in the load function (not sure how wise this is). But now the form data is not sent on submission.

shyakadavis commented 8 months ago

Hey,

Pretty sure with the recent changes to SvelteKit2, top-level promises are no longer awaited so you have to do it yourself.

What @wa-hab suggested seems right. You can even check from Superforms that this is how it's now done.

But now the form data is not send on submission.

I haven't found the time to migrate to SK2 myself, so I'm not sure about this. Might test once I get time.

wa-hab commented 8 months ago

But now the form data is not sent on submission.

nvm, this was a skill issue on my end.

huntabyte commented 8 months ago

Has this issue resolved itself?

wa-hab commented 8 months ago

Yep, all steps in the official docs + calling await on superValidate in the load function should resolve this. The docs for the Form component could be updated to reflect this though.

StevenStavrakis commented 8 months ago

Anyone having trouble with client side validation? I can't reproduce my issue in a StackBlitz. If I copy the docs 1 for 1 only changing the await, it seems that I always get the validation error String must contain at least 2 character(s)

Diezzzzzzz commented 8 months ago

Anyone having trouble with client side validation? I can't reproduce my issue in a StackBlitz. If I copy the docs 1 for 1 only changing the await, it seems that I always get the validation error String must contain at least 2 character(s)

Same here with constraints min() and max().

izcream commented 8 months ago

Anyone having trouble with client side validation? I can't reproduce my issue in a StackBlitz. If I copy the docs 1 for 1 only changing the await, it seems that I always get the validation error String must contain at least 2 character(s)

I got same issues on sveltekit and sveltekit with svelte5

when schema not have .min() its will work fine

huntabyte commented 8 months ago

We aren't supporting Svelte 5 yet, so any issues related to it will be closed until it reaches a stable version.