You are here

public function YamlFormMarkupBase::buildText in YAML Form 8

Build an element as text element.

Parameters

array $element: An element.

array|mixed $value: A value.

array $options: An array of options.

Return value

array A render array representing an element as text.

Overrides YamlFormElementBase::buildText

2 calls to YamlFormMarkupBase::buildText()
ProcessedText::buildText in src/Plugin/YamlFormElement/ProcessedText.php
Build an element as text element.
YamlFormMarkup::buildText in src/Plugin/YamlFormElement/YamlFormMarkup.php
Build an element as text element.
2 methods override YamlFormMarkupBase::buildText()
ProcessedText::buildText in src/Plugin/YamlFormElement/ProcessedText.php
Build an element as text element.
YamlFormMarkup::buildText in src/Plugin/YamlFormElement/YamlFormMarkup.php
Build an element as text element.

File

src/Plugin/YamlFormElement/YamlFormMarkupBase.php, line 72

Class

YamlFormMarkupBase
Provides a base 'markup' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function buildText(array &$element, $value, array $options = []) {

  // Hide markup element if it should be only displayed on a 'form'.
  if (empty($element['#display_on']) || $element['#display_on'] == 'form') {
    return [];
  }

  // Must remove #prefix and #suffix.
  unset($element['#prefix'], $element['#suffix']);

  // Since we are not passing this element to the
  // yamlform_container_base_text template we need to replace the default
  // sub elements with the value (ie renderable sub elements).
  if (is_array($value)) {
    $element = $value + $element;
  }
  return $element;
}