protected function Telephone::formatHtmlItem in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/Telephone.php \Drupal\webform\Plugin\WebformElement\Telephone::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
File
- src/
Plugin/ WebformElement/ Telephone.php, line 244
Class
- Telephone
- Provides a 'tel' 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':
$t_args = [
':tel' => 'tel:' . $value,
'@tel' => $value,
];
return $this
->t('<a href=":tel">@tel</a>', $t_args);
default:
return parent::formatHtmlItem($element, $webform_submission, $options);
}
}