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

SPA support questions #523

Open
olehmisar opened this issue Dec 8, 2024 · 5 comments
Open

SPA support questions #523

olehmisar opened this issue Dec 8, 2024 · 5 comments

Comments

@olehmisar
Copy link
Contributor

  1. Why is onUpdate used to submit a form in SPA mode without +page.ts? https://superforms.rocks/concepts/spa#without-a-pagets-file
  2. How to reset a form after it's submitted?
  3. How to reset a form manually?
@ciscoheat
Copy link
Owner

  1. It's the most convenient point to modify the validation result before it's updating the form.
  2. The resetForm option for superForm is default true and will reset the form automatically when a successful validation result occurs.
  3. Use the reset method on the superForm object.

@olehmisar
Copy link
Contributor Author

  1. I mean, why is onUpdate used instead of onSubmit?

@ciscoheat
Copy link
Owner

onSubmit happens when the form is submitted, so you can cancel the submission, modify its data, etc. Then the validation occurs, and the result is sent to onUpdate so you can use the form data in a call to an external API, which is common for SPA forms.

@olehmisar
Copy link
Contributor Author

It does not make sense for me. Sending data to an external api should happen in onSubmit, no? Look at react formik https://formik.org/docs/overview#the-gist

@ciscoheat
Copy link
Owner

No, it should happen when the data is valid and conveniently at hand, that's in onUpdate. onSubmit happens before the data is validated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants