#Form inside a form

12 messages · Page 1 of 1 (latest)

real spoke
#

Hi,

I have a form with some fields and one of the fields has its own component which has a form in it. When I submit this internal field form, the parent form also get's submitted. Is there a way to handle this situation?

I am using v5.10.5 of mantine form

real spoke
#

@tardy trout @hexed schooner is there a mantine way to address this?

tardy trout
#

it is not valid to have a form within a form in html, regardless of mantine/react

#

depending on where you put it, you should separate it somehow

#

for example you could have a modal popup, that you use withinPortal, so it's part of a separate element tree in the document

real spoke
#

I am using the internal form in a Modal so that it could be separated in the element tree, but still the parent onSubmit is getting fired on child on submit

tardy trout
#

make sure your modal is in a portal

#

set withinPortal on the modal

real spoke
#

Yeah I did that, still no luck

#

is there some portalProps that I can provide which can help solve this?

real spoke
#

@hexed schooner can you suggest how to prevent parent form submission when inner form is submitted?