Article

How to insert and attach a webform per content item or node in Drupal 7

Attach a webform inside or per node content item in Drupal 7

For many instances, you will need to have a unique form for each of your webpage. For instance, a product page with an inquiry message for this item. You will find that the usual webform setup will not be ideal for such since a webform can only be used globally and not specific per node. As such, enabling Webform functionality per content type does not seem a straight forward solution either. Before trying to create a custom module or functions, try solution provided by the Webform Default Fields.

  1. Download Webform Default Fields (requires the Webform module)
    https://www.drupal.org/project/webform_default_fields
     
  2. Go to your Content Type where you wish your webforms to be included 
    /admin/structure/types/manage/yourcontenttype
  3. Under Edit > Webform tab, enable both:
    • Enable webform functionality
    • Webform default fields
  4. Save
     
  5. Navigate to Content > Webforms /admin/content/webform. Here you will see a newly created Webform Default Fields Master Node 
     
  6. Edit this form to add in all necessary form components, the way you will normally build up any webform item - components, form settings, etc. 
    At this point, depending on how many nodes are affected by enabling this module, nodes or content items for this content type will now have a master template webform being inserted upon creation, update or save. Therefore, a lot of webform items will be shown in this listing page, each with its corresponding node title. To avoid the confusion, consider renaming your original, template webform for this content type into something identifiable to stand out among the other webforms.
     
  7. To test, try adding/creating new contents for this content type then saving. Upon preview you will now have a corresponding webform for each content item or node.
     
  8. When filled up then submitted, receipient of this form will get the usual email with the node's title in the Subject line.

Downside, disadvantages:

To date, this seems a viable solution only for small to mid volume of contents for the following limitations:

  • Updating the master webform template does not seem to automatically update the already existing forms on previously created nodes
  • Bulk operations seem missing, although there is a reset feature in the webform node template /node/id/webform

Other workarounds and solutions:

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.