You are here

protected function WebformElementBase::formatTextItem in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::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.

See also

_webform_token_get_submission_value()

6 calls to WebformElementBase::formatTextItem()
Password::formatTextItem in src/Plugin/WebformElement/Password.php
Format an element's value as text.
WebformElementBase::formatHtmlItem in src/Plugin/WebformElementBase.php
Format an element's value as HTML.
WebformElementBase::formatTextItems in src/Plugin/WebformElementBase.php
Format an element's items as text.
WebformRating::formatHtmlItem in src/Plugin/WebformElement/WebformRating.php
Format an element's value as HTML.
WebformSignature::formatTextItem in src/Plugin/WebformElement/WebformSignature.php
Format an element's value as text.

... See full list

19 methods override WebformElementBase::formatTextItem()
BooleanBase::formatTextItem in src/Plugin/WebformElement/BooleanBase.php
Format an element's value as text.
ContainerBase::formatTextItem in src/Plugin/WebformElement/ContainerBase.php
Format an element's value as text.
DateBase::formatTextItem in src/Plugin/WebformElement/DateBase.php
Format an element's value as text.
LanguageSelect::formatTextItem in src/Plugin/WebformElement/LanguageSelect.php
Format an element's value as text.
OptionsBase::formatTextItem in src/Plugin/WebformElement/OptionsBase.php
Format an element's value as text.

... See full list

File

src/Plugin/WebformElementBase.php, line 1733

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
  $value = $this
    ->getValue($element, $webform_submission, $options);
  $format = $this
    ->getItemFormat($element);
  if ($format === 'raw') {
    return $value;
  }
  $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;
}