public static function Element::processLegend in Lightning Core 8.3
Same name and namespace in other branches
- 8.5 src/Element.php \Drupal\lightning_core\Element::processLegend()
- 8 src/Element.php \Drupal\lightning_core\Element::processLegend()
- 8.2 src/Element.php \Drupal\lightning_core\Element::processLegend()
- 8.4 src/Element.php \Drupal\lightning_core\Element::processLegend()
Sets descriptions on child elements according to the #legend property.
Parameters
array $element: The unprocessed element.
Return value
array The processed element.
2 calls to Element::processLegend()
- ElementTest::testProcessLegendArray in tests/
src/ Kernel/ ElementTest.php - @covers ::processLegend
- ElementTest::testProcessLegendCallable in tests/
src/ Kernel/ ElementTest.php - @covers ::processLegend
File
- src/
Element.php, line 134
Class
- Element
- Helpful functions for dealing with renderable arrays and elements.
Namespace
Drupal\lightning_coreCode
public static function processLegend(array $element) {
if (!empty($element['#legend'])) {
foreach (RenderElement::children($element) as $key) {
if (is_callable($element['#legend'])) {
$element[$key]['#description'] = $element['#legend']($element[$key]);
}
elseif (isset($element['#legend'][$key])) {
$element[$key]['#description'] = $element['#legend'][$key];
}
}
}
return $element;
}