You are here

function webform_component_parent_keys in Webform 7.4

Same name and namespace in other branches
  1. 6.3 includes/webform.components.inc \webform_component_parent_keys()
  2. 7.3 includes/webform.components.inc \webform_component_parent_keys()

Find a component's parents within a node.

Parameters

object $node: The webform node.

array $component: The component to start with.

string|true $what_to_return: If TRUE, return complete component arrays. Otherwise, return the property of each component named in this parametre.

Return value

array An array with a value for each parent and for the start component, in order ending with start component. What the value is is controlled by $what_to_return.

5 calls to webform_component_parent_keys()
template_preprocess_webform_analysis_component in includes/webform.report.inc
Prerender function for webform-analysis-component.tpl.php.
WebformComponentsTestCase::testWebformComponents in tests/WebformComponentsTestCase.test
Webform module component tests.
webform_conditional_prepare_javascript in includes/webform.conditionals.inc
Loop through all the conditional settings and add needed JavaScript settings.
webform_tokens in ./webform.tokens.inc
Implements hook_tokens().
webform_webform_submission_render_alter in ./webform.module
Implements hook_webform_submission_render_alter().

File

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

Code

function webform_component_parent_keys($node, array $component, $what_to_return = 'form_key') {
  $parents = array(
    $what_to_return === TRUE ? $component : $component[$what_to_return],
  );
  $pid = $component['pid'];
  while ($pid) {
    $parents[] = $what_to_return === TRUE ? $node->webform['components'][$pid] : $node->webform['components'][$pid][$what_to_return];
    $pid = $node->webform['components'][$pid]['pid'];
  }
  return array_reverse($parents);
}