You are here

public function Tab::process in Field Group 8.3

Allows the field group formatter to manipulate the field group array and attach the formatters elements. The process method is called in the #process part of theme layer, and is currently used for forms. The preRender method is called in the #pre_render part of the theme layer, and is currently used for entity displays.

Parameters

array $element: The field group render array.

object $processed_object: The object / entity beïng processed.

Overrides FieldGroupFormatterBase::process

1 call to Tab::process()
Tab::preRender in src/Plugin/field_group/FieldGroupFormatter/Tab.php
Allows the field group formatter to manipulate the field group array and attach the formatters rendering element.

File

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

Class

Tab
Plugin implementation of the 'tab' formatter.

Namespace

Drupal\field_group\Plugin\field_group\FieldGroupFormatter

Code

public function process(&$element, $processed_object) {

  // Keep using preRender parent for BC.
  parent::preRender($element, $processed_object);
  $add = [
    '#type' => 'details',
    '#title' => $this
      ->getLabel(),
    '#description' => $this
      ->getSetting('description'),
    '#group' => $this->group->parent_name,
  ];
  if ($this
    ->getSetting('id')) {
    $add['#id'] = Html::getUniqueId($this
      ->getSetting('id'));
  }
  else {
    $add['#id'] = Html::getUniqueId('edit-' . $this->group->group_name);
  }
  $classes = $this
    ->getClasses();
  if (!empty($classes)) {
    $element += [
      '#attributes' => [
        'class' => $classes,
      ],
    ];
  }
  if ($this
    ->getSetting('formatter') == 'open') {
    $element['#open'] = TRUE;
  }
  if ($this
    ->getSetting('required_fields')) {
    $element['#attached']['library'][] = 'field_group/formatter.tabs';
    $element['#attached']['library'][] = 'field_group/core';
  }
  $element += $add;
}