Same name and namespace in other branches
  1. 7.x includes/common.inc \show()
  2. 8.9.x core/includes/common.inc \show()
  3. 9 core/includes/common.inc \show()

Shows a hidden element for later rendering.

You can also use render($element), which shows the element while rendering it.

The first time render() or RenderInterface::render() is called on an element tree, as each element in the tree is rendered, it is marked with a #printed flag and the rendered children of the element are cached. Subsequent calls to render() or RenderInterface::render() will not traverse the child tree of this element again: they will just use the cached children. So if you want to show an element, be sure to call show() on the element before its parent tree is rendered for the first time, as it will have no effect on subsequent renderings of the parent tree.

Parameters

$element: The element to be shown.

Return value

array The element.

See also

\Drupal\Core\Render\RendererInterface

render()

hide()

7 string references to 'show'
TestForm::buildForm in core/modules/block/tests/modules/block_test/src/Form/TestForm.php
Form constructor.
ViewAddForm::form in core/modules/views_ui/src/ViewAddForm.php
Gets the actual form array to be built.
ViewAddForm::validateForm in core/modules/views_ui/src/ViewAddForm.php
Form validation handler.
WizardPluginBase::buildFilters in core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
Builds the form structure for selecting the view's filters.
WizardPluginBase::buildSorts in core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
Builds the form structure for selecting the view's sort order.

... See full list

File

core/includes/common.inc, line 367
Common functions that many Drupal modules will need to reference.

Code

function show(&$element) {
  $element['#printed'] = FALSE;
  return $element;
}