You are here

public function Tab::preRender in Field Group: Easy Responsive Tabs to Accordion 8

File

src/Plugin/field_group/FieldGroupFormatter/Tab.php, line 26

Class

Tab
Plugin implementation of the 'ertta_tab' formatter.

Namespace

Drupal\field_group_easy_responsive_tabs\Plugin\field_group\FieldGroupFormatter

Code

public function preRender(&$element, $rendering_object) {
  parent::preRender($element, $rendering_object);
  $label = $this
    ->t($this
    ->getLabel());
  $add = [
    '#type' => 'field_group_easy_responsive_tab',
    '#title' => !empty($label) ? Html::escape($label) : '',
    '#description' => $this
      ->getSetting('description'),
    '#theme_wrappers' => [
      'field_group_easy_responsive_tab',
    ],
    '#attributes' => [
      'class' => $this
        ->getClasses(),
    ],
  ];

  // Front-end and back-end on configuration will lead
  // to vertical tabs nested in a separate vertical group.
  if (!empty($this->group->parent_name)) {
    $add['#parents'] = [
      $this->group->parent_name,
    ];
  }
  if ($this
    ->getSetting('id')) {
    $add['#id'] = Html::getId($this
      ->getSetting('id'));
  }
  else {
    $add['#id'] = Html::getId('edit-' . $this->group->group_name);
  }
  $element += $add;
}