You are here

protected function WebformExampleComposite::formatTextItemValue in Webform 6.x

Same name and namespace in other branches
  1. 8.5 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\WebformElement

Code

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['sex'] || $value['date_of_birth'] ? ' -' : '') . ($value['sex'] ? ' ' . $value['sex'] : '') . ($value['date_of_birth'] ? ' (' . $value['date_of_birth'] . ')' : '');
  return $lines;
}