I need to embed a webform inside content, which is a node. How can this be implemented?

5 Answers 5


There are several ways to do this. The method I normally use it to make a custom Panel page for my node. The content area will contain the "node being viewed" as well as a custom block that renders out my form.

The easiest way, though, is to use the Webform module, and you can build your forms with the UI and easily attach them to a content type.

  • I would like to display the webform inside an html element of my content. What function must be used?
    – user7282
    Jun 7, 2012 at 10:55
  • What is the purpose of this?
    – Volker
    Jun 7, 2012 at 11:06
  • This is for a 3 column page. First two columns contains some text and images, while on the third column, there must be a webform
    – user7282
    Jun 7, 2012 at 11:54
  • 1
    @MPD Thanks, I got it working by using Panel module. I created a Custom Panel page, with the required layout. Then I added the webform's node id into one of the columns and it worked.
    – user7282
    Jun 7, 2012 at 13:23

I think this function (embed webform in a node) is available in the latest Webform module.

Goto content > your-webform-node > edit > webform > form settings > advanced settings > available as block.

  • Thanx for explaining about block, but my problem has been to understand how to find "block name". Larzan answer explain it too.
    – j.c
    Aug 3, 2016 at 8:40
  • I think this is the best vanilla solution, meaning no additional modules are required and no backend coding.
    – Timmah
    Apr 22, 2020 at 6:43

In case you are using the webform module mentioned by the others (i prefer that solution too) and want to render the form manually in php use this snippet:

$block = module_invoke('webform', 'block_view', 'client-block-370');
print render($block['content']);

with 370 being the node_id of your webform, the rest of the parameters don't have to be changed.

  • 1
    To find the node_id of the block just go to admin>content(>find content) and mouseover over the webform node. node_id can be read on the bottom left corner of your browser, it's the last part of the url (www.yourdomain.com/node/node_id)
    – j.c
    Aug 3, 2016 at 8:50

To embed a webform inside content, you can create a token which can return a webform content programatically. Or create a block which can render a webform and place the block next or inside the content.

Drupal 8

Here is example how to render a webform:

$output = \Drupal::entityManager()->getViewBuilder('webform')->view($my_form);

You can also embed it as a block entity:

$block = \Drupal\block\Entity\Block::load('myBlockID');
$block_content = \Drupal::entityManager()

Source: How to embed a Webform?

  • Thanks! But maybe consider using entityTypeManager() since entityManager() is deprecated? Jun 14, 2018 at 23:15

If I understand your requirement correctly I think this module will be useful - Webform Template

And using this patch from http://drupal.org/node/1430752(even for version 7.x-1.2) and following the few changes as mentioned in comment #4 you can even select a default template for each content type.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.