You are here

public function BooleanBase::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

1 method overrides BooleanBase::formatText()
YamlFormToggle::formatText in src/Plugin/YamlFormElement/YamlFormToggle.php
Format an element's value as plain text.

File

src/Plugin/YamlFormElement/BooleanBase.php, line 15

Class

BooleanBase
Provides a base 'boolean' class.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function formatText(array &$element, $value, array $options = []) {
  $format = $this
    ->getFormat($element);
  switch ($format) {
    case 'value':
      return $value ? $this
        ->t('Yes') : $this
        ->t('No');
    default:
      return $value ? 1 : 0;
  }
}