src/Money/Module/Transaction/Controller/Transaction.php
public function ajaxModal()
    {
        if (!Server::getInstance()->isAjax() || !Server::getInstance()->isPost()) {
            throw new \RuntimeException();
        }

        $loadCategories  = true;
        $formAction      = '';
        $virtualAccounts = array();

        $params = $this->route->getParameterCollection();
        $modal  = ucfirst($params->getByName('modal_type')->getValue());

        $transactionMapper = new TransactionMapper(Database::get('money'));
        $accountMapper     = new AccountMapper(Database::get('money'));

        switch ($modal) {
            case 'Create':
                $transaction     = $transactionMapper->newDataInstance();
                $accountId       = $params->getByName('id')->getValue();
                $virtualAccounts = $accountMapper->findVirtualAccounts($accountId);
                break;
            case 'Edit':
                $transactionId   = $params->getByName('id')->getValue();
                $transaction     = $transactionMapper->findById($transactionId);
                $accountId       = $transaction->getAccountId();
                $virtualAccounts = $accountMapper->findVirtualAccounts($accountId);
                break;
            case 'Upload':
                $transaction    = $transactionMapper->newDataInstance();
                $accountId      = $params->getByName('id')->getValue();
                $loadCategories = false;
                $formAction     = '/transaction/list/' . $accountId . '?' . Server::getInstance()->get('query');
                break;
            case 'Delete':
                $transactionId  = $params->getByName('id')->getValue();
                $transaction    = $transactionMapper->findById($transactionId);
                $accountId      = $transaction->getAccountId();
                $loadCategories = false;
                break;
            default:
                throw new \Exception('Bad modal type!');
        }

        //~ Verify if account is for current user, else throw error 500
        $account = $this->verifyAccount($accountId);

        if ($loadCategories) {
            $categoryMapper = new CategoryMapper(Database::get('money'));
            $categories     = $categoryMapper->findAllByAccountId($accountId);
            $this->dataCollection->add('categories', $categories);
        }

        $this->dataCollection->add('formAction', $formAction);
        $this->dataCollection->add('transaction', $transaction);
        $this->dataCollection->add('account', $account);
        $this->dataCollection->add('types', Type::getAllTypes());
        $this->dataCollection->add('virtualAccounts', $virtualAccounts);

        return $this->getResponse('Modal/' . $modal, true);
    }
public function ajaxModal()
    {
        if (!Server::getInstance()->isAjax() || !Server::getInstance()->isPost()) {
            throw new \RuntimeException();
        }

        $loadCategories  = true;
        $formAction      = '';
        $virtualAccounts = array();

        $params = $this->route->getParameterCollection();
        $modal  = ucfirst($params->getByName('modal_type')->getValue());

        $transactionMapper = new TransactionMapper(Database::get('money'));
        $accountMapper     = new AccountMapper(Database::get('money'));

        switch ($modal) {
            case 'Create':
                $transaction     = $transactionMapper->newDataInstance();
                $accountId       = $params->getByName('id')->getValue();
                $virtualAccounts = $accountMapper->findVirtualAccounts($accountId);
                break;
            case 'Edit':
                $transactionId   = $params->getByName('id')->getValue();
                $transaction     = $transactionMapper->findById($transactionId);
                $accountId       = $transaction->getAccountId();
                $virtualAccounts = $accountMapper->findVirtualAccounts($accountId);
                break;
            case 'Upload':
                $transaction    = $transactionMapper->newDataInstance();
                $accountId      = $params->getByName('id')->getValue();
                $loadCategories = false;
                $formAction     = '/transaction/list/' . $accountId . '?' . Server::getInstance()->get('query');
                break;
            case 'Delete':
                $transactionId  = $params->getByName('id')->getValue();
                $transaction    = $transactionMapper->findById($transactionId);
                $accountId      = $transaction->getAccountId();
                $loadCategories = false;
                break;
            default:
                throw new \Exception('Bad modal type!');
        }

        //~ Verify if account is for current user, else throw error 500
        $account = $this->verifyAccount($accountId);

        if ($loadCategories) {
            $categoryMapper = new CategoryMapper(Database::get('money'));
            $categories     = $categoryMapper->findAllByAccountId($accountId);
            $this->dataCollection->add('categories', $categories);
        }

        $this->dataCollection->add('formAction', $formAction);
        $this->dataCollection->add('transaction', $transaction);
        $this->dataCollection->add('account', $account);
        $this->dataCollection->add('types', Type::getAllTypes());
        $this->dataCollection->add('virtualAccounts', $virtualAccounts);

        return $this->getResponse('Modal/' . $modal, true);
    }
Return html code for transaction modal edit / create

@return ResponseInterface
@throws \Exception