Call a custom form in node template Following the Form generation example from DrupalAPI (https://api.drupal.org/api/drupal/core!core.api.php/group/form_api/8.1.x), I have an error when I call the form in my template_preprocess_node.

Here's my code.

mymodule/src/Form/ExampleForm.php

namespace Drupal\mymodule\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class ExampleForm extends FormBase {
  public function getFormId() {
    // Unique ID of the form.
    return 'example_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    // Create a $form API array.
    $form['phone_number'] = array(
      '#type' =&gt; 'tel',
      '#title' =&gt; $this-&gt;t('Your phone number')
    );
    return $form;
  }

  public function validateForm(array &amp;$form, FormStateInterface $form_state) {
    // Validate submitted form data.
  }

  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    // Handle submitted form data.
  }
}


mytheme/mytheme.theme

function cmimmo_preprocess_node(&amp;$variables) {
  $variables['simulator_form'] = \Drupal::formBuilder()-&gt;getForm(\Drupal\mymodule\Form\ExampleForm::class);
}


I get the following error:


  InvalidArgumentException: The form argument Drupal\mymodule\Form\ExampleForm is not a valid form. in Drupal\Core\Form\FormBuilder->getFormId() (line 190 of core\lib\Drupal\Core\Form\FormBuilder.php).


Why am I getting that error message? What is wrong with my code?
My Form folder in my module was named "Forms". Be carefull with your file structure. Too bad the error is not very explicit. It should be "not exist" instead of "not valid".