Drupal 8, include a subtemplate in a form I created a Class form, then I can access to the page form and submit it. My form use the default template of my website.

When I submitted the form, I want redirect the user to the form page (the same page) and display some elements in front of page. Theses elements depends on the results of the form has been submitted.

I can easily do that with simples drupal messages, but instead, I would like to show more complex messages. 

I think I can create a little template file and include it in my form. But I haven't any ideas how can I do that in Drupal 8, can you provide me a very simple example or tell me how I can include a sub-template in my form ? 

I think my sub-template looks something like this (Pseudocode, not twig :) ) : 

// the form return an array
    foreach formarray as element
        &lt;h1&gt;element1&lt;h1&gt;
        &lt;p&gt;property1 : {element[property1}&lt;/p&gt;
        &lt;p&gt;property2 : {element[property2}&lt;/p&gt;
        ...
    end foreach
// I include this template in the form, if the formarray is empty, nothing is displayed (when the user load the forme the first time)


Thanks for help !
Most likely you are looking at adding to the "render array" of the page (or form). A render array can refer to a "type" or Render Element, and that type can render into a template.

The scenario of rendering after form submission on the same form can be done within the Form itself by setting the form state to rebuild.

  public function submitForm(array $form, FormStateInterface $form_state) {

    // Set the rebuild state to TRUE to persist $form_state when the form is reloaded.
    $form_state-&gt;setRebuild();
    $form_state-&gt;set('display_extra', TRUE);
  }

  public function buildForm(array $form, FormStateInterface $form_State) {

    // Conditionally display something from form state.
    if ($form_state-&gt;has('display_extra') &amp;&amp; $form_state-&gt;get('display_extra')) {
      // Structure the render array here including setting up a custom RenderElement ('#type'), which has a custom template defined in hook_theme().
      $form['display_something'] = [];

    }

    // Rest of form...

    return $form;
  }