I need to embed a webform inside content, which is a node. How can this be implemented?
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.
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.
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.
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() ->getViewBuilder('block') ->view($block);
Source: How to embed a Webform?
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.