You are here

public function WebformLikert::formatTableColumn in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformLikert.php \Drupal\webform\Plugin\WebformElement\WebformLikert::formatTableColumn()

Format an element's table column value.

Parameters

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

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 WebformElementBase::formatTableColumn

File

src/Plugin/WebformElement/WebformLikert.php, line 337

Class

WebformLikert
Provides a 'likert' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

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