Skip to content

How to implement tanstack submit button outside a form #1454

Discussion options

You must be logged in to vote

Currently I'm using material ui where in a dialog, there's a tanstack form component, wrapping with
useAppForm. In the dialog footer, it contains the buttons that's outside of the form.

I write creating a button submit or expose the form to the component, the handleSubmit is not called.

Is there a way to get around with this?

I agree with @CanRau that example code could help, but this may be the solution to your case:

If a <button type="submit"> is not within a <form>, then it will not trigger its onSubmit event. Instead, you can simply pass onClick={form.handleSubmit} to the button directly.

Does your code allow this structure, or are there still questions?

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tanyongkuan
Comment options

Answer selected by Balastrong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants