function field_group_group_save in Field Group 8.3
Same name and namespace in other branches
- 8 field_group.module \field_group_group_save()
- 7.2 field_group.module \field_group_group_save()
- 7 field_group.module \field_group_group_save()
Saves a group definition.
Parameters
\stdClass $group: A group definition.
\Drupal\Core\Entity\Display\EntityDisplayInterface $display: The display to update if known.
Return value
\Drupal\Core\Entity\Display\EntityDisplayInterface|null The updated entity display.
Throws
\Drupal\Core\Entity\EntityStorageException
6 calls to field_group_group_save()
- EntityDisplayTest::testHtmlElement in tests/
src/ Functional/ EntityDisplayTest.php - Test the html element formatter.
- EntityDisplayTest::testTabs in tests/
src/ Functional/ EntityDisplayTest.php - Test the tabs formatter.
- FieldGroupAddForm::submitForm in src/
Form/ FieldGroupAddForm.php - Form submission handler.
- FieldGroupTestTrait::createGroup in tests/
src/ Functional/ FieldGroupTestTrait.php - Create a new group.
- field_group_field_overview_submit in includes/
field_ui.inc - Submit handler for the overview screens.
File
- ./
field_group.module, line 877 - Allows administrators to attach field groups.
Code
function field_group_group_save($group, $display = NULL) {
if ($display === NULL) {
if ($group->context == 'form') {
$display = EntityFormDisplay::load($group->entity_type . '.' . $group->bundle . '.' . $group->mode);
}
elseif ($group->context == 'view') {
$display = EntityViewDisplay::load($group->entity_type . '.' . $group->bundle . '.' . $group->mode);
}
}
// If no display was found. It doesn't exist yet, create it.
if (!isset($display)) {
if ($group->context == 'form') {
$display = EntityFormDisplay::create([
'targetEntityType' => $group->entity_type,
'bundle' => $group->bundle,
'mode' => $group->mode,
])
->setStatus(TRUE);
}
elseif ($group->context == 'view') {
$display = EntityViewDisplay::create([
'targetEntityType' => $group->entity_type,
'bundle' => $group->bundle,
'mode' => $group->mode,
])
->setStatus(TRUE);
}
}
if (isset($display)) {
// Remove label from the format_settings.
unset($group->format_settings['label']);
$data = (array) $group;
unset($data['group_name'], $data['entity_type'], $data['bundle'], $data['mode'], $data['form'], $data['context']);
$display
->setThirdPartySetting('field_group', $group->group_name, $data);
$display
->save();
}
return $display;
}