Display webform in a modal I am trying to display my webform in a modal (including error/validation messages inside the modal). I am following this approach for a custom drupal form which is not a webform. I am wondering whether this is possible at all with webforms and in case it is, what I need to take into account to make it run?

The first problem I am having is the following code line from the example's TeacherContactController.php

$modal_form = $this-&gt;formBuilder-&gt;getForm('Drupal\tl_session\Form\TeacherForm');


When I try to use this in my own controller, I cannot get the webform's proper namespace + id. When I check my webform with devel it says:

[__CLASS__] =&gt; Drupal\webform\Entity\Webform
  [id] =&gt; add_news_webform


But I get a "The form argument Drupal\webform\Entity\Webform\webform-submission-add_news_webform-form is not a valid form" error. I tried many things, but did not succeed.

How can I get the webform with formBuilder and what else am I missing here (like webform specific ajax settings etc.)?
Displaying a weform in modal (might be called popup as well) it is a lot simpler than you thought
Lets assume your webform has URL /contact than you can create a link in the following manner
&lt;a class=&quot;use-ajax&quot; data-dialog-type=&quot;modal&quot; href=&quot;/contact&gt;Contact US&lt;/a&gt;

Pressing that link will have your form open in a modal with error validation and messages inside the modal
NOTE:
At least in my case I had to also add the following hook_preprocess_page in the .theme file
function THEMENAME_preprocess_page(&amp;$vars) {
    //custom logic of when to include the library
    // ....
    $vars['#attached']['library'][] =  'core/drupal.dialog.ajax';  
}

Some people have reported that this is not needed but I assume some other module included this library for them ...