Working in D8, I am trying to insert a form into an already created page/template file.
I am using webforms, and on the webform submission page (that lists the submission details), I am trying to insert a custom form to do some additional stuff. I already have the form generated, but I cannot find the correct way to insert the form into the template/page.
I tried using \Drupal::formBuilder()->getForm(form_name)
in the twig template where I wanted it, but Drupal didn't like that.
I then tried to use hook_page_bottom
and hook_page_top
, but that quite literally attaches it to the very top of the page, or very bottom of the page (outside of the bounds of the theme/template), not where I want it to be.
I am already overriding the template using the naming convention webform-submission--webform-machine-name.html.twig.
I am assuming since you can override the default templates for webform submissions, that the webform module implements hook_theme
or some other similar hook. Is there a way I can hook into this hook and pass the form off as a variable, then just render it in the actual template using {{ form }}
, or do I need to create my own override and pass both the submission data and the form data into it?
I miss the days when I could just use $form = drupal_get_form();
and print render($form);
inside of the template exactly where I wanted it.