protected function WebformCompositeBase::prepareMultipleWrapper in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::prepareMultipleWrapper()
Set multiple element wrapper.
Parameters
array $element: An element.
Overrides WebformElementBase::prepareMultipleWrapper
1 method overrides WebformCompositeBase::prepareMultipleWrapper()
- WebformCustomComposite::prepareMultipleWrapper in src/
Plugin/ WebformElement/ WebformCustomComposite.php - Set multiple element wrapper.
File
- src/
Plugin/ WebformElement/ WebformCompositeBase.php, line 189
Class
- WebformCompositeBase
- Provides a base for composite elements.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function prepareMultipleWrapper(array &$element) {
if (empty($element['#multiple']) || !$this
->supportsMultipleValues()) {
return;
}
parent::prepareMultipleWrapper($element);
// Set #header.
if (!empty($element['#multiple__header'])) {
$element['#header'] = TRUE;
// Set #element.
// We don't need to get the initialized composite elements because
// they will be initialized, prepared, and finalize by the
// WebformMultiple (wrapper) element.
// @see \Drupal\webform\Element\WebformMultiple::processWebformMultiple
$element['#element'] = [];
$composite_elements = $this
->getCompositeElements();
foreach (Element::children($composite_elements) as $composite_key) {
$composite_element = $composite_elements[$composite_key];
// Transfer '#{composite_key}_{property}' from main element to composite
// element.
foreach ($element as $property_key => $property_value) {
if (strpos($property_key, '#' . $composite_key . '__') === 0) {
$composite_property_key = str_replace('#' . $composite_key . '__', '#', $property_key);
$composite_element[$composite_property_key] = $property_value;
}
}
$element['#element'][$composite_key] = $composite_element;
}
}
}