Form elements removed during custom page render In a table, I keep a collection of nodes, text and forms that should be rendered on particular generated pages. I run through a loop that builds an output variable based on the the tables type and values. Worked fine in D7 and the text and node pieces are working fine in D8, after some adjustments.  The piece I'm having trouble with is adding a form to the output variable.  

In D7: 

$output = "a variety of html";
$formname = "triagezipform"; //would be filled in by field value
$form = drupal_get_form($formname);
$output .= render($form);


In D8:

$output = "a variety of html";
$formname = "triagezipform"; //would be filled in by field value
$form = \Drupal::formBuilder()-&gt;getForm('Drupal\triage\Form\'.$formname);
$output .= render($form);


I see the form properly at the end of the function that builds the output, but as it goes through Drupal page rendering the Form elements are removed. 

Pre-page rendering:

&lt;div class='triage-action-form ta-contrast-background noprint '&gt;
  &lt;form class="triagezipform" data-drupal-selector="triagezipform"               action="form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM" method="post" id="triagezipform"
                  accept-charset="UTF-8"&gt;
&lt;div class="form-item js-form-item form-type-textfield js-form-type-textfield form-item-triage-zip js-form-item-triage-zip form-group"&gt;
  &lt;label for="edit-triage-zip" class="control-label"&gt;Enter zipcode where your legal issue is&lt;/label&gt;
  &lt;input data-drupal-selector="edit-triage-zip" class="form-text form-control" type="text"id="edit-triage-zip" name="triage_zip" value="04643" size="20" maxlength="5"/&gt;
&lt;/div&gt;
&lt;/form&gt;


Post-page rendering:

&lt;div class="form-item js-form-item form-type-textfield js-form-type-textfield form-item-triage-zip js-form-item-triage-zip form-group"&gt;
          Enter zipcode where your legal issue is
&lt;/div&gt;


Any ideas of how I get forms to show properly when being built this way?
How are you then using $output? Are you putting it into ['#markup'] in your build array?

If so markup content will strip all sorts out. So either you can put $form as a separate item in your build array and there's no need to run it through render()

Or you can use drupal's "inline_template" rather than #markup in the build array