Submitting multiple forms at once.

Is there a way to have multiple forms in a single view have individual submit buttons as well as a “global” submit button that validates form fields across all forms at once ?

A Submit button submits the data from the current form, and it’s not valid to embed one form within another form.

My hunch is that the only way to accomplish this would be to write some JavaScript that would gather the data from all the forms on the page and submit that, and assign that function to a “Global Submit” <button>.

Hmm… Thanks. I was just thinking of asking (if anyone knew an easy or a more straight forward approach) before I take the JS approach.

If it were possible to define a Submit button to submit something other than the form in which it’s embedded, there would be. But it’s not. A Submit button is bound to its form. While it’s possible to bind multiple Submit buttons to the same form, it’s not possible to bind a Submit button to more than one form. Therefore, JavaScript is necessary to collect data from the multiple forms for submission.

See: The Form element and Submit Button specs for more details.

1 Like