You are here

function show in Drupal 10

Same name and namespace in other branches
  1. 8 core/includes/common.inc \show()
  2. 7 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

The element.

See also

\Drupal\Core\Render\RendererInterface

render()

hide()

1 call to show()
template_preprocess_file_widget_multiple in core/modules/file/file.field.inc
Prepares variables for multi file form widget templates.
12 string references to 'show'
drupal7.php in core/modules/tracker/tests/fixtures/drupal7.php
A database agnostic dump for testing purposes.
drupal7.php in core/modules/migrate_drupal/tests/fixtures/drupal7.php
A database agnostic dump for testing purposes.
Node::buildFilters in core/modules/node/src/Plugin/views/wizard/Node.php
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters().
Node::defaultDisplayFiltersUser in core/modules/node/src/Plugin/views/wizard/Node.php
Retrieves filter information based on user input for the default display.
NodeRevision::defaultDisplayFiltersUser in core/modules/node/src/Plugin/views/wizard/NodeRevision.php
Retrieves filter information based on user input for the default display.

... See full list

File

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

Code

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