function social_core_entity_form_display_alter in Open Social 10.2.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_core/social_core.module \social_core_entity_form_display_alter()
- 10.0.x modules/social_features/social_core/social_core.module \social_core_entity_form_display_alter()
- 10.1.x modules/social_features/social_core/social_core.module \social_core_entity_form_display_alter()
Implements hook_entity_form_display_alter().
File
- modules/
social_features/ social_core/ social_core.module, line 87 - The Social core module.
Code
function social_core_entity_form_display_alter(EntityFormDisplayInterface $form_display, array $context) {
$field_groups = $form_display
->getThirdPartySettings('field_group');
if (!isset($field_groups['group_settings'])) {
return;
}
$fields = [];
// List of all fields which are split by section.
foreach ($field_groups as $field_group) {
$fields = array_merge($fields, $field_group['children']);
}
// List of all fields which aren't split by section.
$fields = array_diff(array_keys($form_display
->getComponents()), $fields);
if ($fields) {
$field_groups['group_settings']['children'] = array_merge($field_groups['group_settings']['children'], $fields);
$form_display
->setThirdPartySetting('field_group', 'group_settings', $field_groups['group_settings'])
->save();
}
}