You are here

public function Accordion::preRender in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/field_group/FieldGroupFormatter/Accordion.php \Drupal\field_group\Plugin\field_group\FieldGroupFormatter\Accordion::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/Accordion.php, line 27

Class

Accordion
Plugin implementation of the 'accordion' formatter.

Namespace

Drupal\field_group\Plugin\field_group\FieldGroupFormatter

Code

public function preRender(&$element, $rendering_object) {
  parent::preRender($element, $rendering_object);
  $form_state = new FormState();
  $element += array(
    '#type' => 'field_group_accordion',
    '#effect' => $this
      ->getSetting('effect'),
  );
  if ($this
    ->getSetting('id')) {
    $element['#id'] = Html::getId($this
      ->getSetting('id'));
  }
  $classes = $this
    ->getClasses();
  if (!empty($classes)) {
    $element += array(
      '#attributes' => array(
        'class' => $classes,
      ),
    );
  }
  \Drupal\field_group\Element\Accordion::processAccordion($element, $form_state);
}