How do I add a custom button to the entity form?

To add a custom button to the EntityForm you will need to extend the AdminBasicEntityController. For example MyCustomAdminController. In here, you will want to override the modifyEntityForm method. (You may also need to modify the modifyAddEntityFrom method, this can, at times, be different when a new entity is being added/created). Here you can create a new EntityFormAction, configure it, and add it to the EntityForm.

    @Override
    protected void modifyEntityForm(EntityForm entityForm, Map<String, String> pathVars) throws Exception {
        super.modifyEntityForm(entityForm, pathVars);

        EntityFormAction stopTestAction = new EntityFormAction("My Action")
                .withDisplayText("My Action")
                .withUrlPostfix("/my-action");
        entityForm.addAction(stopTestAction);
    }

This will create a button that will go along the Save and Delete actions.

Once you have the button in place, you will need to create the method with the corresponding request mapping in the controller to handle the request.

Note: Make sure you set the sectionKey.

More information about admin controller can be found here:
https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/admin/admin-controllers