You could put the markup for the form in the before and after for the webpart contents, or just make sure that your webpart or form is wrapped in the appropriate css classes. You may also need some js for the submit and modal close. Sometimes they don't behave well inside, which requires some tweaks through js or customizations.