Start form as modal, from the controller I see a lot of examples of modal forms. But in all these example the modal is started from a current form. There is always a link-button involved. I would like to start a form as a modal from the controller by using:  

$form = \Drupal::formBuilder()-&gt;getForm($formId);
return $form;

Can someone give me an example of which extra code is needed to show the form ($formId) as a modal??
I did an example of this a while ago. Basically I defined a route, and that controller returned an AjaxResponse:

mymodule.growl:
  path: '/mymodule/growl'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController::growl'
  requirements:
    _permission: 'access content'


Basic controller:

namespace Drupal\mymodule\Controller;

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Controller\ControllerBase;
use Drupal\igrowl\Ajax\GrowlCommand;

class MyModuleController extends ControllerBase {
  public function growl() {
    $options = GrowlCommand::defaultOptions();
    $options['message'] = 'This is a message.';
    $options['title'] = 'Hello';
    $options['icon'] = 'feather-check';
    $options['type'] = 'success';

    $response = new AjaxResponse();
    $response-&gt;addCommand(new GrowlCommand($options));
    return $response;
  }
}


Any link hitting that route fired that Command. So, anytime someone clicks a link going to your defined route, it should create a modal.

You basically want to return a form (use the form builder service provided by ControllerBase instead of the static container) and at a basic level, use OpenModalDialogCommand (or supply your own modal js with custom Command). AjaxResponse will take care of the rest.