You are here

public function WebformMapping::getTableColumn in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformMapping.php \Drupal\webform\Plugin\WebformElement\WebformMapping::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/WebformMapping.php, line 302

Class

WebformMapping
Provides a 'mapping' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

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 sources.
  foreach ($element['#source'] as $source_key => $source_title) {
    $columns['element__' . $key . '__' . $source_key] = [
      'title' => ($is_title_displayed ? $title . ': ' : '') . $source_title,
      'sort' => TRUE,
      'default' => FALSE,
      'key' => $key,
      'element' => $element,
      'delta' => $source_key,
      'source_key' => $source_key,
      'plugin' => $this,
    ];
  }
  return $columns;
}