How to insert and attach a webform per content item or node 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.
- Download Webform Default Fields (requires the Webform module)
- Go to your Content Type where you wish your webforms to be included
- Under Edit > Webform tab, enable both:
- Enable webform functionality
- Webform default fields
- Navigate to Content > Webforms /admin/content/webform. Here you will see a newly created Webform Default Fields Master Node
- 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.
- 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.
- When filled up then submitted, receipient of this form will get the usual email with the node's title in the Subject line.
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:
- Tokens to load the title of the node from where the webform was submitted
- Contact and Contact Form on Node
- Webform block and Context (custom function)
- Recreate nodes / contents to load the webform default, you may use node clone integration on VBO; tested using the Node Export but the latter seems to work instead; then using the same VBO filters of similar, filter old content nodes for deletion retaining the cloned items; run the same to update URLs (for instance removing "Clone of" from the titles)