protected function WebformSignature::formatHtmlItem in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformSignature.php \Drupal\webform\Plugin\WebformElement\WebformSignature::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/ WebformSignature.php, line 76
Class
- WebformSignature
- Provides a 'signature' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function formatHtmlItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
$format = $this
->getItemFormat($element);
switch ($format) {
case 'image':
if (empty($value)) {
return '[' . $this
->t('not signed') . ']';
}
$src = $this
->getImageUrl($element, $webform_submission, $options);
return $src ? [
'#type' => 'html_tag',
'#tag' => 'img',
'#attributes' => [
'src' => $src,
'alt' => $this
->t('Signature'),
'class' => [
'webform-signature-image',
],
],
'#attached' => [
'library' => [
'webform/webform.element.signature',
],
],
] : '[' . $this
->t('not valid') . ']';
default:
return parent::formatHtmlItem($element, $webform_submission, $options);
}
}