protected function WebformElementBase::formatHtmlItem in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::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.
8 calls to WebformElementBase::formatHtmlItem()
- Color::formatHtmlItem in src/
Plugin/ WebformElement/ Color.php - Format an element's value as HTML.
- Email::formatHtmlItem in src/
Plugin/ WebformElement/ Email.php - Format an element's value as HTML.
- Telephone::formatHtmlItem in src/
Plugin/ WebformElement/ Telephone.php - Format an element's value as HTML.
- Url::formatHtmlItem in src/
Plugin/ WebformElement/ Url.php - Format an element's value as HTML.
- WebformCodeMirror::formatHtmlItem in src/
Plugin/ WebformElement/ WebformCodeMirror.php - Format an element's value as HTML.
19 methods override WebformElementBase::formatHtmlItem()
- Color::formatHtmlItem in src/
Plugin/ WebformElement/ Color.php - Format an element's value as HTML.
- ContainerBase::formatHtmlItem in src/
Plugin/ WebformElement/ ContainerBase.php - Format an element's value as HTML.
- Email::formatHtmlItem in src/
Plugin/ WebformElement/ Email.php - Format an element's value as HTML.
- OptionsBase::formatHtmlItem in src/
Plugin/ WebformElement/ OptionsBase.php - Format an element's value as HTML.
- Table::formatHtmlItem in src/
Plugin/ WebformElement/ Table.php - Format an element's value as HTML.
File
- src/
Plugin/ WebformElementBase.php, line 1693
Class
- WebformElementBase
- Provides a base class for a webform element.
Namespace
Drupal\webform\PluginCode
protected function formatHtmlItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$format = $this
->getItemFormat($element);
$value = $this
->formatTextItem($element, $webform_submission, [
'prefixing' => FALSE,
] + $options);
if ($format === 'raw') {
return $value;
}
// Build a render that used #plain_text so that HTML characters are escaped.
// @see \Drupal\Core\Render\Renderer::ensureMarkupIsSafe
$build = [
'#plain_text' => $value,
];
$options += [
'prefixing' => TRUE,
];
if ($options['prefixing']) {
if (isset($element['#field_prefix'])) {
$build['#prefix'] = $element['#field_prefix'];
}
if (isset($element['#field_suffix'])) {
$build['#suffix'] = $element['#field_suffix'];
}
}
return $build;
}