A form might have multiple buttons. Clicking any of them will validate the form, but each button might do additional task.
For example, a form of writing article have three submit buttons:
- A Save button saves the article and keeps the current publishing status
- A Save and publish button saves and publishes the article
- A Save as draft button saves the article as draft
These buttons will execute form validation when being clicked.
In order to archive this case, first, we need to trigger the success.form.fv event to perform custom handler when the form is valid.
Next, use the getSubmitButton() method to determine which button is clicked.