public function UIOverrideProvider::referenceFormDetailsRestructure in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/src/UIOverrideProvider.php \Drupal\bibcite_entity\UIOverrideProvider::referenceFormDetailsRestructure()
Restructure form elements to the details view.
Parameters
array $element: Element render array.
File
- modules/
bibcite_entity/ src/ UIOverrideProvider.php, line 160
Class
- UIOverrideProvider
- Collection of hardcoded overrides for reference form and view.
Namespace
Drupal\bibcite_entityCode
public function referenceFormDetailsRestructure(array &$element) {
if ($this->config
->get('ui_override.enable_form_override')) {
$field_groups = $this
->getGroupedFields();
// Place all details elements under the title.
$weight = $element['title']['#weight'];
foreach ($field_groups as $group_id => $group) {
foreach ($group['elements'] as $field_id) {
if (isset($element[$field_id]) && $element[$field_id]['#access']) {
if (!isset($element[$group_id])) {
$element[$group_id] = [
'#type' => 'details',
'#title' => $group['title'],
'#weight' => ++$weight,
];
}
$element[$group_id][$field_id] = $element[$field_id];
unset($element[$field_id]);
}
}
}
}
}