function _name_component_layout in Name Field 8
Same name and namespace in other branches
- 7 name.module \_name_component_layout()
Sorts the widgets according to the language type.
1 call to _name_component_layout()
- Name::preRender in src/
Element/ Name.php - This function themes the element and controls the title display.
File
- ./
name.module, line 614 - Defines an API for displaying and inputing names.
Code
function _name_component_layout(&$element, $layout = 'default') {
$weights = [
'asian' => [
'family' => 1,
'middle' => 2,
'given' => 3,
'title' => 4,
// The 'generational' value is removed from the display.
'generational' => 5,
'credentials' => 6,
],
'eastern' => [
'title' => 1,
'family' => 2,
'given' => 3,
'middle' => 4,
'generational' => 5,
'credentials' => 6,
],
'german' => [
'title' => 1,
'credentials' => 2,
'given' => 3,
'middle' => 4,
'family' => 5,
// The 'generational' value is removed from the display.
'generational' => 7,
],
];
if (isset($weights[$layout])) {
foreach ($weights[$layout] as $component => $weight) {
if (isset($element[$component])) {
$element[$component]['#weight'] = $weight;
}
}
}
if ($layout == 'asian' || $layout == 'german') {
if (isset($element['generational'])) {
$element['generational']['#default_value'] = '';
$element['generational']['#access'] = FALSE;
}
}
}