protected function Email::formatHtmlItem in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/Email.php \Drupal\webform\Plugin\WebformElement\Email::formatHtmlItem()
Format an element's value as HTML.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array|string The element's value formatted as HTML or a render array.
Overrides WebformElementBase::formatHtmlItem
1 call to Email::formatHtmlItem()
- WebformEmailMultiple::formatHtmlItem in src/
Plugin/ WebformElement/ WebformEmailMultiple.php - Format an element's value as HTML.
1 method overrides Email::formatHtmlItem()
- WebformEmailMultiple::formatHtmlItem in src/
Plugin/ WebformElement/ WebformEmailMultiple.php - Format an element's value as HTML.
File
- src/
Plugin/ WebformElement/ Email.php, line 52
Class
- Provides a 'email' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function formatHtmlItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
if (empty($value)) {
return '';
}
$format = $this
->getItemFormat($element);
switch ($format) {
case 'link':
return [
'#type' => 'link',
'#title' => $value,
'#url' => $this->pathValidator
->getUrlIfValid('mailto:' . $value),
];
default:
return parent::formatHtmlItem($element, $webform_submission, $options);
}
}