Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Container.php

function 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\Element

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal