WebformExampleComposite.php in Webform 6.x
File
modules/webform_example_composite/src/Plugin/WebformElement/WebformExampleComposite.php
View source
<?php
namespace Drupal\webform_example_composite\Plugin\WebformElement;
use Drupal\webform\Plugin\WebformElement\WebformCompositeBase;
use Drupal\webform\WebformSubmissionInterface;
class WebformExampleComposite extends WebformCompositeBase {
protected function formatHtmlItemValue(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
return $this
->formatTextItemValue($element, $webform_submission, $options);
}
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;
}
}