You are here

public function YamlFormLikert::formatTableColumn in YAML Form 8

Format an element's table column value.

Parameters

array $element: An element.

array|mixed $value: A value.

array $options: An array of options returned from ::getTableColumns().

Return value

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

Overrides YamlFormElementBase::formatTableColumn

File

src/Plugin/YamlFormElement/YamlFormLikert.php, line 296

Class

YamlFormLikert
Provides a 'likert' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function formatTableColumn(array $element, $value, array $options = []) {
  if (isset($options['question_key'])) {
    $question_key = $options['question_key'];
    $question_value = isset($value[$question_key]) ? $value[$question_key] : '';
    return YamlFormOptionsHelper::getOptionText($question_value, $element['#answers']);
  }
  else {
    return $this
      ->formatHtml($element, $value);
  }
}