Skip to main content
3 of 3
added 68 characters in body
norman.lol
  • 19.1k
  • 6
  • 75
  • 129

I've just been encountering a similar problem. And solved it like following.

In my MYMODULE.module file:

function MYMODULE_theme($existing, $type, $theme, $path) { return [ 'mythemename' => [ 'render element' => 'form', 'template' => 'my-template-name', ], ]; } 

In the $form:

$form['#theme'] = 'mythemename'; 

And finally in the my-template-name.html.twig template:

<div class="someclass"> {{ form }} </div>