You are here

public function TextFormat::formatHtml in YAML Form 8

Format an element's value as HTML.

Parameters

array $element: An element.

array|mixed $value: A value.

array $options: An array of options.

Return value

array|string The element's value formatted as an HTML string or a render array.

Overrides YamlFormElementBase::formatHtml

1 call to TextFormat::formatHtml()
TextFormat::formatText in src/Plugin/YamlFormElement/TextFormat.php
Format an element's value as plain text.

File

src/Plugin/YamlFormElement/TextFormat.php, line 100

Class

TextFormat
Provides a 'text_format' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function formatHtml(array &$element, $value, array $options = []) {
  $value = isset($value['value']) ? $value['value'] : $value;
  $format = isset($value['format']) ? $value['format'] : $this
    ->getFormat($element);
  switch ($format) {
    case 'raw':
      return $value;
    case 'value':
    default:
      return check_markup($value, $format);
  }
}