function RenderElementBase::preRenderGroup
Same name in other branches
- 11.x core/lib/Drupal/Core/Render/Element/RenderElementBase.php \Drupal\Core\Render\Element\RenderElementBase::preRenderGroup()
Adds members of this group as actual elements for rendering.
Parameters
array $element: An associative array containing the properties and children of the element.
Return value
array The modified element with all group members.
2 calls to RenderElementBase::preRenderGroup()
- FormElement::preRenderGroup in core/
lib/ Drupal/ Core/ Render/ Element/ FormElement.php - RenderElement::preRenderGroup in core/
lib/ Drupal/ Core/ Render/ Element/ RenderElement.php
2 methods override RenderElementBase::preRenderGroup()
- FormElement::preRenderGroup in core/
lib/ Drupal/ Core/ Render/ Element/ FormElement.php - RenderElement::preRenderGroup in core/
lib/ Drupal/ Core/ Render/ Element/ RenderElement.php
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ RenderElementBase.php, line 163
Class
- RenderElementBase
- Provides a base class for render element plugins.
Namespace
Drupal\Core\Render\ElementCode
public static function preRenderGroup($element) {
// The element may be rendered outside of a Form API context.
if (!isset($element['#parents']) || !isset($element['#groups'])) {
return $element;
}
// Inject group member elements belonging to this group.
$parents = implode('][', $element['#parents']);
$children = Element::children($element['#groups'][$parents]);
if (!empty($children)) {
foreach ($children as $key) {
// Break references and indicate that the element should be rendered as
// group member.
$child = (array) $element['#groups'][$parents][$key];
$child['#group_details'] = TRUE;
// Inject the element as new child element.
$element[] = $child;
$sort = TRUE;
}
// Re-sort the element's children if we injected group member elements.
if (isset($sort)) {
$element['#sorted'] = FALSE;
}
}
if (isset($element['#group'])) {
// Contains form element summary functionalities.
$element['#attached']['library'][] = 'core/drupal.form';
$group = $element['#group'];
// If this element belongs to a group, but the group-holding element does
// not exist, we need to render it (at its original location).
if (!isset($element['#groups'][$group]['#group_exists'])) {
// Intentionally empty to clarify the flow; we simply return $element.
}
elseif (!empty($element['#group_details'])) {
// Intentionally empty to clarify the flow; we simply return $element.
}
elseif (Element::children($element['#groups'][$group])) {
$element['#printed'] = TRUE;
}
}
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.