public function TextFormat::formatText in YAML Form 8
Format an element's value as plain text.
Parameters
array $element: An element.
array|mixed $value: A value.
array $options: An array of options.
Return value
string The element's value formatted as plain text or a render array.
Overrides YamlFormElementBase::formatText
File
- src/
Plugin/ YamlFormElement/ TextFormat.php, line 116
Class
- TextFormat
- Provides a 'text_format' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function formatText(array &$element, $value, array $options = []) {
$format = isset($value['format']) ? $value['format'] : $this
->getFormat($element);
switch ($format) {
case 'raw':
return $value;
case 'value':
default:
$html = $this
->formatHtml($element, $value);
// Convert any HTML to plain-text.
$html = MailFormatHelper::htmlToText($html);
// Wrap the mail body for sending.
$html = MailFormatHelper::wrapMail($html);
return $html;
}
}