Webform Component Roles keeps the component role id's in a separate table, so this information is not attached to the components, and is not loaded.

This is necessary if you want to clone components, I needed it in particular to work with https://drupal.org/project/webform_template

The attached patch will make sure to attach the component role data when the node is loaded, not sure if this is the best way, but its working for what i need.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sdsheridan’s picture

Given the updates reflected in the 1.5 version, does this now simply become:

/**
 * Implements hook_node_load().
 */
function webform_component_roles_node_load($nodes, $types) {
  foreach ($nodes as $node) {
    if (isset($node->webform['components'])) {
      foreach ($node->webform['components'] as &$component) {
        $component['role_control']['roles'] = _webform_component_roles_component_roles($component['nid'], $component['cid']);
      }
    }
  }
}

In addition, for the D6 version (to keep everything in synch), would it be:

function webform_component_roles_nodeapi(&$node, $op, $a3, $a4) {
  switch ( $op ) {
    case 'load' :
      if (isset($node->webform['components'])) {
        foreach ($node->webform['components'] as &$component) {
          $component['role_control']['roles'] = _webform_component_roles_component_roles($component['nid'], $component['cid']);
        }
      }
      break;
  }
}

Does that change still work with webform_template and cloning?

Shawn

sdsheridan’s picture

Assigned: Unassigned » sdsheridan
Status: Needs review » Active

Updating status and assigning to myself.