public static function Element::disableButtons in Lightning Core 8
Same name and namespace in other branches
- 8.5 src/Element.php \Drupal\lightning_core\Element::disableButtons()
- 8.2 src/Element.php \Drupal\lightning_core\Element::disableButtons()
- 8.3 src/Element.php \Drupal\lightning_core\Element::disableButtons()
- 8.4 src/Element.php \Drupal\lightning_core\Element::disableButtons()
Pre-render function to disable all buttons in a renderable element.
Parameters
array $element: The renderable element.
Return value
array The renderable element with all buttons (at all levels) disabled.
File
- src/
Element.php, line 80
Class
- Element
- Helpful functions for dealing with renderable arrays and elements.
Namespace
Drupal\lightning_coreCode
public static function disableButtons(array $element) {
if (isset($element['#type'])) {
$element['#access'] = !in_array($element['#type'], [
'button',
'submit',
'image_button',
]);
}
// Recurse into child elements.
foreach (RenderElement::children($element) as $key) {
if (is_array($element[$key])) {
$element[$key] = static::disableButtons($element[$key]);
}
}
return $element;
}