protected function WebformCompositeBase::formatCompositeTextItems in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::formatCompositeTextItems()
Format a composite as a list of plain text items.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array|string A composite as a list of plain text items.
2 calls to WebformCompositeBase::formatCompositeTextItems()
- WebformCompositeBase::formatTextItem in src/
Plugin/ WebformElement/ WebformCompositeBase.php - Format an element's value as text.
- WebformCompositeBase::formatTextItemValue in src/
Plugin/ WebformElement/ WebformCompositeBase.php - Format composite element value into lines of text.
File
- src/
Plugin/ WebformElement/ WebformCompositeBase.php, line 526
Class
- WebformCompositeBase
- Provides a base for composite elements.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function formatCompositeTextItems(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$format = $this
->getItemFormat($element);
$items = [];
$composite_elements = $this
->getInitializedCompositeElement($element);
foreach (RenderElement::children($composite_elements) as $composite_key) {
$composite_element = $composite_elements[$composite_key];
$composite_title = isset($composite_element['#title']) && $format !== 'raw' ? $composite_element['#title'] : $composite_key;
$composite_value = $this
->formatCompositeText($element, $webform_submission, [
'composite_key' => $composite_key,
] + $options);
if (is_array($composite_value)) {
$composite_value = \Drupal::service('renderer')
->renderPlain($composite_value);
}
if ($composite_value !== '') {
$items[$composite_key] = "{$composite_title}: {$composite_value}";
}
}
return $items;
}