How can I add a custom form to the output of a controller class? I have a controller in my custom module.  Inside this controller I need to render a whole bunch of different things (some basic html, multiple forms, etc).  My main problem is I can't figure out how to


Properly load a Drupal 8 custom form
Then get that form into an acceptable format to pass to the #markup output of the controller.
Keep in mind this form is mixed in with other html that will be a mish-mash of lots of stuff not shown here (I've trimmed it down to show a basic example)


My controller code looks like this currently:

&lt;?php

namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;

class SingleNodeProcessor extends ControllerBase {

  public function processSingle($nid) {    
    $markup = '&lt;div class="process-heading"&gt;' . $this-&gt;t('My custom Form Is below but there will be alot more html than just the form. So this is just an example.') . '&lt;/div&gt;';

    $form = $this-&gt;formBuilder()-&gt;getForm('Drupal\my_module\Form\MyFormClassGoesHere', $nid);
    $markup .= $form; //this is a render array, how do I turn it to html so it can pass to #markup??

    return [
      '#type' =&gt; 'markup',
      '#markup' =&gt; $markup,
    ];
  }
}
I think you want to return a render array, instead of markup. Because the from needs to stay as a render array, your best bet it to bring your content content to the same format instead of the other way. In your example:

public function processSingle($nid) {
  $build = [];
  $build['heading'] = [
    '#type' =&gt; 'markup',
    '#markup' =&gt; '&lt;div class="process-heading"&gt;' . $this-&gt;t('My custom Form Is below but there will be alot more html than just the form. So this is just an example.') . '&lt;/div&gt;',
  ];
  $build['form'] = $this-&gt;formBuilder()-&gt;getForm('Drupal\my_module\Form\MyFormClassGoesHere', $nid);
  return $build;
}