protected function OptionsBase::formatTextItem in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/OptionsBase.php \Drupal\webform\Plugin\WebformElement\OptionsBase::formatTextItem()
Format an element's value as text.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
string The element's value formatted as text.
Overrides WebformElementBase::formatTextItem
See also
_webform_token_get_submission_value()
1 call to OptionsBase::formatTextItem()
- WebformImageSelect::formatTextItem in modules/
webform_image_select/ src/ Plugin/ WebformElement/ WebformImageSelect.php - Format an element's value as text.
1 method overrides OptionsBase::formatTextItem()
- WebformImageSelect::formatTextItem in modules/
webform_image_select/ src/ Plugin/ WebformElement/ WebformImageSelect.php - Format an element's value as text.
File
- src/
Plugin/ WebformElement/ OptionsBase.php, line 364
Class
- OptionsBase
- Provides a base 'options' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
$format = $this
->getItemFormat($element);
switch ($format) {
case 'raw':
return $value;
case 'description':
if (isset($element['#options'])) {
$options_description = $this
->hasProperty('options_description_display');
if ($options_description) {
$description = WebformOptionsHelper::getOptionDescription($value, $element['#options'], $options_description);
if ($description) {
return MailFormatHelper::htmlToText($description);
}
}
}
return '';
case 'value':
default:
if (isset($element['#options'])) {
$options_description = $this
->hasProperty('options_description_display');
$value = WebformOptionsHelper::getOptionText($value, $element['#options'], $options_description);
}
$options += [
'prefixing' => TRUE,
];
if ($options['prefixing']) {
if (isset($element['#field_prefix'])) {
$value = strip_tags($element['#field_prefix']) . $value;
}
if (isset($element['#field_suffix'])) {
$value .= strip_tags($element['#field_suffix']);
}
}
return $value;
}
}