function Container::preRenderContainer
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Element/Container.php \Drupal\Core\Render\Element\Container::preRenderContainer()
- 8.9.x core/lib/Drupal/Core/Render/Element/Container.php \Drupal\Core\Render\Element\Container::preRenderContainer()
- 11.x core/lib/Drupal/Core/Render/Element/Container.php \Drupal\Core\Render\Element\Container::preRenderContainer()
- 11.x Container.php \Drupal\Core\Render\Element\Container::preRenderContainer()
Prevents optional containers from rendering if they have no children.
Parameters
array $element: An associative array containing the properties and children of the container.
Return value
array The modified element.
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ Container.php, line 99
Class
- Container
- Provides a render element that wraps child elements in a container.
Namespace
Drupal\Core\Render\ElementCode
public static function preRenderContainer($element) {
// Do not render optional container elements if there are no children.
if (empty($element['#printed']) && !empty($element['#optional']) && !Element::getVisibleChildren($element)) {
$element['#printed'] = TRUE;
}
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.