I am trying to display my webform using MYTHEME.theme file but I did not get any result.

I am using code below:

function THEMENAME_preprocess_webform(&$vars) {
  $wfid = $vars["element"]["#webform_id"];
  $wf = \Drupal\webform\Entity\Webform::load($wfid);
  $vars["title"] = $wf->label();

How can I show the webform on a node?

  • You need to override the webform.html.twig template and print the {{ title }} variable. – user72672 Sep 11 '19 at 10:42
  • Can't you simply add an entity reference field to the node? And then reference your webform? And then under Manage Display settings set it to display the full webform? – leymannx Sep 11 '19 at 10:42
  • I don't get it. What is your current code snippet supposed to do exactly? It doesn't match the title of your question... – leymannx Sep 11 '19 at 10:44
  • issue is solved. thanks – user3292506 Sep 12 '19 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.