public function AccordionItem::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 AccordionItem::process()
- AccordionItem::preRender in src/
Plugin/ field_group/ FieldGroupFormatter/ AccordionItem.php - Allows the field group formatter to manipulate the field group array and attach the formatters rendering element.
File
- src/
Plugin/ field_group/ FieldGroupFormatter/ AccordionItem.php, line 30
Class
- AccordionItem
- Plugin implementation of the 'accordion_item' formatter.
Namespace
Drupal\field_group\Plugin\field_group\FieldGroupFormatterCode
public function process(&$element, $processed_object) {
// Keep using preRender parent for BC.
parent::preRender($element, $processed_object);
$element += [
'#type' => 'field_group_accordion_item',
'#effect' => $this
->getSetting('effect'),
'#title' => $this
->getLabel(),
// Prevent \Drupal\content_translation\ContentTranslationHandler::addTranslatabilityClue()
// from adding an incorrect suffix to the field group title.
'#multilingual' => TRUE,
];
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.details';
}
if ($this
->getSetting('formatter') == 'open') {
$element['#open'] = TRUE;
}
foreach ($element as $key => $value) {
if (is_array($value) && !empty($value['#children_errors'])) {
$element['#open'] = TRUE;
}
}
}