Best practice form in modal

Hi there,

I was wondering how to best structure a form in a modal.

For what I understand a submit button needs to be a child element of the form it is submitting.

But I want to use the footer button of the modal to submit the form. To be able to do this, I make the form the root element of the modal. Then I place the header, body and footer of the modal in the form.

Formfields are placed in de modal body element.

It works, but I would like to know if there is a better approach.