You are here

public function Tabs::preRender in Field Group 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/field_group/FieldGroupFormatter/Tabs.php \Drupal\field_group\Plugin\field_group\FieldGroupFormatter\Tabs::preRender()

Allows the field group formatter to manipulate the field group array and attach the formatters rendering element.

Parameters

array $element: The field group render array.

object $rendering_object: The object / entity beïng rendered.

Overrides FieldGroupFormatterBase::preRender

File

src/Plugin/field_group/FieldGroupFormatter/Tabs.php, line 65

Class

Tabs
Plugin implementation of the 'horizontal_tabs' formatter.

Namespace

Drupal\field_group\Plugin\field_group\FieldGroupFormatter

Code

public function preRender(&$element, $rendering_object) {
  $this
    ->process($element, $rendering_object);
  if ($this
    ->getSetting('direction') == 'vertical') {
    $form_state = new FormState();
    $complete_form = [];
    $element = VerticalTabs::processVerticalTabs($element, $form_state, $complete_form);
  }
  else {
    $form_state = new FormState();
    $complete_form = [];
    $element = HorizontalTabs::processHorizontalTabs($element, $form_state, $complete_form);
  }

  // Make sure the group has 1 child. This is needed to succeed at form_pre_render_vertical_tabs().
  // Skipping this would force us to move all child groups to this array, making it an un-nestable.
  $element['group']['#groups'][$this->group->group_name] = [
    0 => [],
  ];
  $element['group']['#groups'][$this->group->group_name]['#group_exists'] = TRUE;
}