You are here

public function Fieldset::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 Fieldset::process()
Fieldset::preRender in src/Plugin/field_group/FieldGroupFormatter/Fieldset.php
Allows the field group formatter to manipulate the field group array and attach the formatters rendering element.

File

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

Class

Fieldset
Plugin implementation of the 'fieldset' formatter.

Namespace

Drupal\field_group\Plugin\field_group\FieldGroupFormatter

Code

public function process(&$element, $processed_object) {
  $element += [
    '#type' => 'fieldset',
    '#title' => $this
      ->getLabel(),
    '#attributes' => [],
    '#description' => $this
      ->getSetting('description'),
    // Prevent \Drupal\content_translation\ContentTranslationHandler::addTranslatabilityClue()
    // from adding an incorrect suffix to the field group title.
    '#multilingual' => TRUE,
  ];

  // When a fieldset has a description, an id is required.
  if ($this
    ->getSetting('description') && !$this
    ->getSetting('id')) {
    $element['#id'] = Html::getUniqueId($this->group->group_name);
  }
  if ($this
    ->getSetting('id')) {
    $element['#id'] = Html::getUniqueId($this
      ->getSetting('id'));
  }
  $classes = $this
    ->getClasses();
  if (!empty($classes)) {
    $element['#attributes'] += [
      'class' => $classes,
    ];
  }
  if ($this
    ->getSetting('required_fields')) {
    $element['#attached']['library'][] = 'field_group/formatter.fieldset';
    $element['#attached']['library'][] = 'field_group/core';
  }
}