You are here

protected function WebformCompositeBase::initializeCompositeElementsRecursive in Webform 6.x

Same name in this branch
  1. 6.x src/Element/WebformCompositeBase.php \Drupal\webform\Element\WebformCompositeBase::initializeCompositeElementsRecursive()
  2. 6.x src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::initializeCompositeElementsRecursive()
Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::initializeCompositeElementsRecursive()

Initialize a composite's elements recursively.

Parameters

array $element: A render array for the current element.

array $composite_elements: A render array containing a composite's elements.

2 calls to WebformCompositeBase::initializeCompositeElementsRecursive()
WebformCompositeBase::initializeCompositeElements in src/Plugin/WebformElement/WebformCompositeBase.php
Initialize and cache #webform_composite_elements.
WebformCustomComposite::initializeCompositeElements in src/Plugin/WebformElement/WebformCustomComposite.php
Initialize and cache #webform_composite_elements.

File

src/Plugin/WebformElement/WebformCompositeBase.php, line 1287

Class

WebformCompositeBase
Provides a base for composite elements.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function initializeCompositeElementsRecursive(array &$element, array &$composite_elements) {
  foreach ($composite_elements as $composite_key => &$composite_element) {
    if (WebformElementHelper::property($composite_key)) {
      continue;
    }

    // Set composite id, key, and parent key.
    // @see \Drupal\webform\Entity\Webform::initElementsRecursive
    if (isset($element['#webform_id'])) {
      $composite_element['#webform_composite_id'] = $element['#webform_id'] . '--' . $composite_key;
    }
    if (isset($element['#webform_key'])) {
      $composite_element['#webform_composite_key'] = $element['#webform_key'] . '__' . $composite_key;
      $composite_element['#webform_composite_parent_key'] = $element['#webform_key'];
    }
    $this
      ->initializeCompositeElementsRecursive($element, $composite_element);
  }
}