You are here

function webform_component_clone in Webform 7.3

Same name and namespace in other branches
  1. 5.2 webform_components.inc \webform_component_clone()
  2. 6.3 includes/webform.components.inc \webform_component_clone()
  3. 6.2 webform_components.inc \webform_component_clone()
  4. 7.4 includes/webform.components.inc \webform_component_clone()

Recursively insert components into the database.

Parameters

$node: The node object containing the current webform.

$component: A full component containing fields from the component form.

1 call to webform_component_clone()
webform_component_edit_form_submit in includes/webform.components.inc
Submit handler for webform_component_edit_form().

File

includes/webform.components.inc, line 890
Webform module component handling.

Code

function webform_component_clone(&$node, &$component) {
  $original_cid = $component['cid'];
  $component['cid'] = NULL;
  $new_cid = webform_component_insert($component);
  $component['cid'] = $new_cid;
  if (webform_component_feature($component['type'], 'group')) {
    foreach ($node->webform['components'] as $cid => $child_component) {
      if ($child_component['pid'] == $original_cid) {
        $child_component['pid'] = $new_cid;
        webform_component_clone($node, $child_component);
      }
    }
  }
  return $new_cid;
}