[Feature request] Pass on return value of onSubmit inside handleSubmit
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 https://github.com/TanStack/form/compare/main...zoodirector:tanstack-form:handle-submit-results
and to illustrate the use case with an example: https://github.com/TanStack/form/compare/main...zoodirector:tanstack-form:handle-submit-results-example
Thanks for looking into it! Kindly, Nico
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
Apologies, but we're going to close this issue in favor of the API as documented here: https://github.com/TanStack/form/issues/989