1.20.x common.inc | hide(&$element) |
Hides an element from later rendering.
The first time render() or backdrop_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 backdrop_render() will not traverse the child tree of this element again: they will just use the cached children. So if you want to hide an element, be sure to call hide() 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.
Note that hide() should only be used when doing the final printing of a render element, such as in a template. If wanting to hide a form element earlier in the process, such as in hook_form_alter(), you should set #access instead, like this:
$element['#access'] = FALSE
Parameters
$element: The element to be hidden.
Return value
The element.:
See also
render()
show()
File
- includes/
common.inc, line 6869 - Common functions that many Backdrop modules will need to reference.
Code
function hide(&$element) {
$element['#printed'] = TRUE;
return $element;
}