You are here

public function YamlFormLikert::getTableColumn in YAML Form 8

Get element's table column(s) settings.

Parameters

array $element: An element.

Return value

array An associative array containing an element's table column(s).

Overrides YamlFormElementBase::getTableColumn

File

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

Class

YamlFormLikert
Provides a 'likert' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function getTableColumn(array $element) {
  $key = $element['#yamlform_key'];
  $title = $element['#title'] ?: $key;
  $is_title_displayed = YamlFormElementHelper::isTitleDisplayed($element);

  // Get the main composite element, which can't be sorted.
  $columns = parent::getTableColumn($element);
  $columns['element__' . $key]['sort'] = FALSE;

  // Get individual questions.
  foreach ($element['#questions'] as $question_key => $question_label) {
    $columns['element__' . $key . '__' . $question_key] = [
      'title' => ($is_title_displayed ? $title . ': ' : '') . $question_label,
      'sort' => TRUE,
      'default' => FALSE,
      'key' => $key,
      'element' => $element,
      'delta' => $question_key,
      'question_key' => $question_key,
      'plugin' => $this,
    ];
  }
  return $columns;
}