How to create a custom backend form processing before submission and validation in Magento 2

- Magento 2

Magento 2 Development

For the standard jQuery .submit() method your submit event handler will be triggered after the standard form validation, but it could be inconvenient. Luckily, Magento 2 backend forms fire a custom beforeSubmit event:

Github code

Github code

Thus, you can easily subscribe to it and run a custom processing before form both validation and submission. Examine the following example:


Other tips from the Cookbook