public function AccordionItem::preRender in Field Group 8
Same name and namespace in other branches
- 8.3 src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php \Drupal\field_group\Plugin\field_group\FieldGroupFormatter\AccordionItem::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/ AccordionItem.php, line 31 
Class
- AccordionItem
- Plugin implementation of the 'accordion_item' formatter.
Namespace
Drupal\field_group\Plugin\field_group\FieldGroupFormatterCode
public function preRender(&$element, $rendering_object) {
  parent::preRender($element, $rendering_object);
  $element += array(
    '#type' => 'field_group_accordion_item',
    '#open' => $this
      ->getSetting('formatter') == 'open' ? TRUE : FALSE,
    '#description' => $this
      ->getSetting('description'),
    '#title' => Drupal::translation()
      ->translate($this
      ->getLabel()),
  );
  if ($this
    ->getSetting('id')) {
    $element['#id'] = Html::getId($this
      ->getSetting('id'));
  }
  $classes = $this
    ->getClasses();
  if (!empty($classes)) {
    $element += array(
      '#attributes' => array(
        'class' => $classes,
      ),
    );
  }
  if ($this
    ->getSetting('required_fields')) {
    $element['#attached']['library'][] = 'field_group/formatter.details';
  }
}