You are here

function webform_default_fields_node_insert in Webform Default Fields 7

Same name and namespace in other branches
  1. 7.4 webform_default_fields.module \webform_default_fields_node_insert()
  2. 7.3 webform_default_fields.module \webform_default_fields_node_insert()

Implements hook_insert().

File

./webform_default_fields.module, line 84

Code

function webform_default_fields_node_insert($node) {
  if ($nid = variable_get('webform_default_fields_nid_' . $node->type, 0)) {
    module_load_include('inc', 'webform', 'includes/webform.components');
    webform_ensure_record($node);
    $master_node = node_load($nid, NULL, TRUE);
    foreach ($master_node->webform['components'] as $component) {
      $component['nid'] = $node->nid;
      $node->webform['components'][] = $component;
      webform_component_insert($component);
    }
  }
}