Change theme template for one form I try to change a the theme template for one form. I do not want to use theme suggestions as I only want to use a different theme in one case, and if I add a suggestion, it is always used. (maybe I'm wrong.)

I'm doing:

in my controller:

$form = \Drupal::service('entity.form_builder')-&gt;getForm($entity);

$form['#theme_wrappers'][] = 'user_register_form_01';

return $form;


in my .module

function mymodule_theme() {
  return [
    'user_register_form_01' =&gt; [
      'render element' =&gt; 'form',
      'template' =&gt; 'user-register-form-01',
    ],
  ];
}


in user-register-form-01.html.twig:

&lt;form{{ attributes }}&gt;

  {{ form.field_1 }}
  {{ form.field_2 }}
  {{ form.account.pass }}
  {{ form.account.mail }}

  {{ form.form_build_id }}
  {{ form.form_id }}
  {{ form.actions }}

&lt;/form&gt;


Everything seems to be rendered correctly, but the form does not work/submit. I think it is because attributes does not contain any action information. There is one more attributes variable inside form but I don't know how to call it as when I dump it it is prefixed with # 

dump(form|keys) returns 

array (size=49)
  0 =&gt; string '#attributes' (length=11)
  1 =&gt; string '#attached' (length=9)
  ...
  47 =&gt; string '#children' (length=9)



I don't know how to access this as form.#attributes doesn't work and form.attributes results empty.
Also this #attributes seems not to contain the needed form submission information. But it seems that inside #children the #attributes does.


I am thankfull for any hint or help.
Have you looked into the Context module for this (https://www.drupal.org/project/context)? One of the "reactions" is to change the theme. You can do it by system path.