<?php

class Admin_FormAction_UserInvite_Create extends Admin_FormAction_Abstract {

    protected function _getRequiredFields() {
        return [];
    }

    protected function _checkData(CM_Params $params, CM_Http_Response_View_Form $response, CM_Form_Abstract $form) {
        if (!$response->getViewer(true)->getRoles()->contains(Denkmal_Role::ADMIN)) {
            $response->addError($response->getRender()->getTranslation('Not Allowed'));
        }
    }

    protected function _process(CM_Params $params, CM_Http_Response_View_Form $response, CM_Form_Abstract $form) {
        /** @var Denkmal_Params $params */
        $inviter = $response->getViewer(true);
        $email = $params->has('email') ? $params->getString('email') : null;
        $expires = $params->getDate('expires');
        $sendEmail = $params->getBoolean('sendEmail');

        $userInvite = Denkmal_Model_UserInvite::create($inviter, $email, $expires);

        if ($sendEmail) {
            $email = new Denkmal_Mail_UserInvite($userInvite);
            $email->send();
        }
    }
}

<?php

class Admin_FormAction_UserInvite_Create extends Admin_FormAction_Abstract {

    protected function _getRequiredFields() {
        return [];
    }

    protected function _checkData(CM_Params $params, CM_Http_Response_View_Form $response, CM_Form_Abstract $form) {
        parent::_checkData($params, $response, $form);
        $email = $params->has('email') ? $params->getString('email') : null;
        $sendEmail = $params->getBoolean('sendEmail');

        if (null === $email && true === $sendEmail) {
            $response->addError($response->getRender()->getTranslation('Einladung kann nicht verschickt werden weil E-Mail fehlt.'), 'sendEmail');
        }
    }

    protected function _process(CM_Params $params, CM_Http_Response_View_Form $response, CM_Form_Abstract $form) {
        /** @var Denkmal_Params $params */
        $inviter = $response->getViewer(true);
        $email = $params->has('email') ? $params->getString('email') : null;
        $expires = $params->getDate('expires');
        $sendEmail = $params->getBoolean('sendEmail');

        $userInvite = Denkmal_Model_UserInvite::create($inviter, $email, $expires);

        if ($sendEmail) {
            $email = new Denkmal_Mail_UserInvite($userInvite);
            $email->send();
        }
    }
}

Add form error for sendEmail but not email on invite form
Add form error for sendEmail but not email on invite form
