public static function Name::preRender in Name Field 8
This function themes the element and controls the title display.
1 call to Name::preRender()
- name_element_pre_render in ./
name.module - This function themes the element and controls the title display.
File
- src/
Element/ Name.php, line 141
Class
- Name
- Provides a name render element.
Namespace
Drupal\name\ElementCode
public static function preRender($element) {
$layouts = name_widget_layouts();
$layout = $layouts['stacked'];
if (!empty($element['#widget_layout']) && isset($layouts[$element['#widget_layout']])) {
$layout = $layouts[$element['#widget_layout']];
}
if (!empty($layout['library'])) {
if (!isset($element['#attached']['library'])) {
$element['#attached']['library'] = [];
}
$element['#attached']['library'] += $layout['library'];
}
$attributes = new Attribute($layout['wrapper_attributes']);
$element['_name'] = [
'#prefix' => '<div' . $attributes . '>',
'#suffix' => '</div>',
];
foreach (_name_translations() as $key => $title) {
if (isset($element[$key])) {
$element['_name'][$key] = $element[$key];
unset($element[$key]);
}
}
if (!empty($element['#component_layout'])) {
_name_component_layout($element['_name'], $element['#component_layout']);
}
return $element;
}