Open crutchcorn opened 3 days ago
Hi @crutchcorn can I be assigned this ticket?
Hey @crutchcorn . Thank you very much for taking up my ideas of #949 ! However, I don't find this API proposal of yours particularly advantageous. It would require me to put the business logic that handles the server response (e.g. navigating to different routes after submissions) inside the onSubmit
function of the form. It is an inversion of control where not necessary. For me it would feel more natural if the form API would return control after the successful submission of the form and not wrap around the business logic that follows afterwards. I think that my suggested design in #949 would allow for a better decoupling of code. For example if I want to reuse the same redirection logic in different forms.
But that is just my opinion. I guess I could also live with the API suggested above.
Imagine a usecase where the user wants two buttons, they both send the item to the backend (after form validation) but one goes back to the list and the other goes to a different page, like a step 2 or a detail page.
To solve this, we're thinking of introducing a new API called
onSubmitMeta
that allows you to pass arguments to theonSubmit
function via ameta
field.This API might look something like this:
By having
onSubmitMeta
it enables us to have a few features on top of passing properties such as:meta
field from the FW itselfThis API should be purely additive, so it may not make it into v1 of TanStack Form