public function WebformLikert::getTableColumn in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformLikert.php \Drupal\webform\Plugin\WebformElement\WebformLikert::getTableColumn()
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 WebformElementBase::getTableColumn
File
- src/
Plugin/ WebformElement/ WebformLikert.php, line 308
Class
- WebformLikert
- Provides a 'likert' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function getTableColumn(array $element) {
$key = $element['#webform_key'];
$title = $element['#title'] ?: $key;
$is_title_displayed = WebformElementHelper::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;
}