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

[Feature request] Pass on return value of onSubmit inside handleSubmit #949

Open
zoodirector opened this issue Sep 16, 2024 · 0 comments
Open

Comments

@zoodirector
Copy link

zoodirector commented Sep 16, 2024

I would like to pass on the return value of options.onSubmit() inside form.handleSubmit() to be able to process returned values of the server response. For example the form could be valid but an error occurs when the form should be saved on the server. Or the form is stored successfully and I want to do something with the returned value.

Imagine the following use case: In an administration interface I have a view to create a new item with a form. To save I have two buttons: "Save and return to list view" and "Save and keep editing". Both buttons call form.handleSubmit() in their onClick handler. But depending on the result of the function they will continue in a different way.

I made the according commit here main...zoodirector:tanstack-form:handle-submit-results

and to illustrate the use case with an example: main...zoodirector:tanstack-form:handle-submit-results-example

Thanks for looking into it!
Kindly,
Nico

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

1 participant