Block not showing input fields I have a block as part of my custom module, I was it to show 2 text boxes (Input &amp; Output) and have a generate button. I cant get it to show the input boxes! It seems they are being stripped out for some reason? I have tried with and without twig but my example below is without twig to keep it simple:

    &lt;?php

/**
 * @file
 * Contains \Drupal\mymodule\Plugin\Block\GenerateBlock.
 */

namespace Drupal\mymodule\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a 'generateblock' block.
 *
 * @Block(
 *   id = "generate_block",
 *   admin_label = @Translation("Generate Code"),
 *   category = @Translation("mymodule")
 * )
 */
class generateblock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    // $twig = \Drupal::service('twig');
    // $template = $twig-&gt;loadTemplate(drupal_get_path('module', 'mymodule') . '/templates/generatecode.html.twig');
    // $output = $template-&gt;render([]);
    $output='&lt;div id="GenerateCodeBox" class="featured-boxes featured-boxes-style-8"&gt;
    &lt;div class="col-md-12"&gt;
    &lt;div class="featured-box featured-box-primary featured-box-text-left" style="height: 301px;"&gt;
    &lt;div class="box-content"&gt;
    &lt;div class="row"&gt;
    &lt;div class="col-md-9"&gt;
    &lt;h2&gt;Generate &lt;strong&gt;Access Code&lt;/strong&gt;&lt;/h2&gt;
    &lt;/div&gt;

    &lt;div class="col-md-3"&gt;
    &lt;div class="align-right"&gt;
    &lt;h2&gt;&lt;i class="fa fa-twitter"&gt;‌&lt;/i&gt;&lt;/h2&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="row"&gt;
    &lt;div class="col-md-12"&gt;
    &lt;div class="input-group"&gt; 
    &lt;input class="form-control" id="codeToCheck" placeholder="Enter Input" type="text" value="" /&gt; &lt;span class="input-group-btn" id="generateMe"&gt;&lt;button class="btn btn-default mr-xs mb-sm" type="button"&gt;Set&lt;/button&gt;
    &lt;/span&gt;
    &lt;/div&gt;

    &lt;div class="input-group"&gt;&lt;input class="form-control" id="validationCode" placeholder="" readonly="readonly" type="text" value="" /&gt; &lt;span class="input-group-btn" id="copyCode"&gt;&lt;button class="btn btn-default mr-xs mb-sm" type="button"&gt;Copy&lt;/button&gt;&lt;/span&gt;&lt;/div&gt;
    &lt;a class="btn btn-lg btn-primary mr-xs mb-lg" href="#" type="button"&gt;Learn More&lt;/a&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;';

    return array(
      '#type' =&gt; 'markup',
      '#markup' =&gt; $output,
    );
  }

}


I do not know why the inputs are being stripped out? What am i missing

**** Update ****

I have changed my code to the following and it is no longer stripping out the input boxes but it feels a bit "hacky" Do I need to specify a different render type or something:

class AccessCode extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $twig = \Drupal::service('twig');
    $template = $twig-&gt;loadTemplate(drupal_get_path('module', 'mymodule') . '/templates/accesscode.html.twig');
    $output = $template-&gt;render([]);

    return array(
      '#markup' =&gt; $output,
      '#allowed_tags' =&gt; ['input','span','div','a','button','h2','strong','i',], 
    );
  }
try to follow best practises:
as no need to render anything on your get the twig template as drupal core handles this. 

module structure:

mymodule


mymodule.module
mymodule.info.yml
mymodule.libraries.yml
templates (dir)
-- templates/accesscode.html.twig
src (dir) 
-- src/Plugin/Block
----- AccessCode.php


in mymodule.module

/**
 * Implements hook_theme().
 */
function mymodule_theme($existing, $type, $theme, $path) {
    return [
      'accesscode_block' =&gt; [
        'variables' =&gt; [
          'test' =&gt; null,
         ],
         'template' =&gt; 'accesscode', 
//no need for full accesscode.html.twig as drupal knows. 
      ],
    ];
} 


then in your src/Plugin/Block/  AccessCode.php

 /**
 * {@inheritdoc}
 */
public function build() {
  $build = [];
  $build['my-block'] = [
      '#theme' =&gt; 'accesscode_block',
      '#test' =&gt; 1234,
  ];
  // Attach js or css easier. 
  $build['#attached']['library'][] = 'mymodule/mymodule-accesscode';

// Could even add a form element like ..
 $build['some_field'] = [
   '#type' =&gt; 'textfield',
   '#title' =&gt; 'My Field:',
 ];
  return $build;
}


then in your accesscode.html.twig you can use the twig var {{test}}