function name_element_expand in Name Field 8
Same name and namespace in other branches
- 6 name.module \name_element_expand()
- 7 name.module \name_element_expand()
The #process callback to create the element.
1 string reference to 'name_element_expand'
- Name::getInfo in src/
Element/ Name.php - Returns the element properties for this element.
File
- ./
name.module, line 380 - Defines an API for displaying and inputing names.
Code
function name_element_expand($element, &$form_state, $complete_form) {
$element['#tree'] = TRUE;
if (empty($element['#value'])) {
$element['#value'] = [];
}
$parts = _name_translations();
$components = $element['#components'];
$min_components = (array) $element['#minimum_components'];
foreach ($parts as $component => $title) {
if (!isset($components[$component]['exclude'])) {
$element[$component] = name_element_render_component($components, $component, $element, isset($min_components[$component]));
$attributes = [
'class' => [
'name-component-wrapper',
'name-' . $component . '-wrapper',
],
];
if ($component == 'credentials' && !empty($element['#credentials_inline'])) {
$attributes['class'][] = 'name-component-break';
}
$attributes = new Attribute($attributes);
$element[$component]['#prefix'] = '<div' . $attributes . '>';
$element[$component]['#suffix'] = '</div>';
}
}
return $element;
}