We are using webforms and webform template modules on our site. We have created two webforms (Enquiry and Contact) and used them as webform template forms for some content types

Webform template settings enter image description here

Default webform template setting

Set deafult templates for different content types

Now if I make any changes to default template webform say "enquiry form" webform those changes do not get reflected across all the nodes of type using this template in this case it is "Accommodation".

I made some changes to email template of enquiry webform say I add a new custom subject and save the webform email settings form.

enter image description here

Now I want this change to get reflected across all nodes of accommodation type which are using enquiry form template but for that I had to edit and save individual nodes. This is easy when we have lesser number of nodes we can update each node for template changes to work but if we have say 100 nodes then this process becomes impractical.

Is there any way we can update nodes attached to the webform after updating the webform template.

I tried to resolve this by custom form alter where I update each node programmatically on default template edit form sublit

case 'webform_email_edit_form':
  if ($form['node']['#value']->title == 'Enquiry Form') {
    $form['#submit'][] = 'enquiry_webform_email_custom_submit';

custom submit function enquiry_webform_email_custom_submit

$query = new EntityFieldQuery();  

$result = $query->entityCondition('entity_type', 'node')
          ->entityCondition('bundle', 'accomodation')
  if (isset($result['node'])) {
    $accommodation_nids = array_keys($result['node']);
    $accommodation_items = entity_load('node', $accommodation_nids);
    // dpm($accommodation_items);
    foreach ($accommodation_items as $key => $value) {
      // dpm($value);
      if (count($value->field_acc_hotel_id) == 0) {
        $node = node_load($key);
        $node->body[$node->language][0]['value'] .= "\nA line of text added by program.";
        drupal_set_message('Node ' . $key . ' has been updated.');

This function works properly after I make any change to email template this submit handler updates all the nodes using webform template. But this does not update the email template I am still getting old settings for email even after the default template is changed.

Below Image - Webform attached to individual node email settings after updating default webform template and running the custom code.

webform of individual node

  • Try to clear drupal cache.
    – Cool
    Commented Nov 14, 2013 at 15:32


Your Answer

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

Browse other questions tagged or ask your own question.