You are here

function webform_component_clone in Webform 6.2

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. 7.4 includes/webform.components.inc \webform_component_clone()
  4. 7.3 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 ./webform_components.inc

File

./webform_components.inc, line 567
Webform module components handling.

Code

function webform_component_clone(&$node, &$component) {
  $original_cid = $component['cid'];
  unset($component['cid']);
  $new_cid = webform_component_insert($component);
  if ($component['type'] == 'fieldset') {
    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;
}