protected function WebformExampleComposite::formatTextItemValue in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_example_composite/src/Plugin/WebformElement/WebformExampleComposite.php \Drupal\webform_example_composite\Plugin\WebformElement\WebformExampleComposite::formatTextItemValue()
Format composite element value into lines of text.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array Composite element values converted into lines of text.
Overrides WebformCompositeBase::formatTextItemValue
1 call to WebformExampleComposite::formatTextItemValue()
- WebformExampleComposite::formatHtmlItemValue in modules/
webform_example_composite/ src/ Plugin/ WebformElement/ WebformExampleComposite.php - Format composite element value into lines of text.
File
- modules/
webform_example_composite/ src/ Plugin/ WebformElement/ WebformExampleComposite.php, line 39
Class
- WebformExampleComposite
- Provides a 'webform_example_composite' element.
Namespace
Drupal\webform_example_composite\Plugin\WebformElementCode
protected function formatTextItemValue(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
$lines = [];
$lines[] = ($value['first_name'] ? $value['first_name'] : '') . ($value['last_name'] ? ' ' . $value['last_name'] : '') . ($value['gender'] || $value['date_of_birth'] ? ' -' : '') . ($value['gender'] ? ' ' . $value['gender'] : '') . ($value['date_of_birth'] ? ' (' . $value['date_of_birth'] . ')' : '');
return $lines;
}