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

Closed
zoodirector opened this issue Sep 16, 2024 · 2 comments
Closed

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

@zoodirector
Copy link
Author

Hello @crutchcorn ! I was wondering if you (or someone else) did already have the time to look at this? If my reasoning for requesting this feature is not clear I would be happy to explain some more. Or if I just did not understand the correct usage of the form API and I could get the same functionality in another way I would be happy to learn about it.

Kindly,
Nico

@crutchcorn
Copy link
Member

Apologies, but we're going to close this issue in favor of the API as documented here: #989

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