protected function FieldManager::addToDefaultFormDisplay in Scheduled Updates 8
Parameters
$entity_type:
$bundle:
$label:
$field_name:
2 calls to FieldManager::addToDefaultFormDisplay()
- FieldManager::createNewReferenceField in src/
FieldManager.php - Creates a new Entity Reference field that will reference the updates of this type.
- FieldManager::updateExistingReferenceFields in src/
FieldManager.php - Update existing Entity reference fields to have the bundle as a target.
File
- src/
FieldManager.php, line 262 - Contains \Drupal\scheduled_updates\FieldManager.
Class
- FieldManager
- Field Manager for handling fields for Scheduled Updates.
Namespace
Drupal\scheduled_updatesCode
protected function addToDefaultFormDisplay($entity_type, $bundle, $label, $field_name) {
// Load the default entity form display or create one if it doesn't exist.
/** @var EntityFormDisplay $formDisplay */
$formDisplay = EntityFormDisplay::load("{$entity_type}.{$bundle}.default");
if (!$formDisplay) {
$formDisplay = EntityFormDisplay::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => 'default',
'status' => TRUE,
]);
}
$form_options = [
'type' => 'inline_entity_form_complex',
'weight' => '11',
'settings' => [
'override_labels' => TRUE,
'label_singular' => $label,
'label_plural' => $label . 's',
'allow_new' => TRUE,
'match_operator' => 'CONTAINS',
'allow_existing' => FALSE,
],
];
$formDisplay
->setComponent($field_name, $form_options);
$formDisplay
->save();
}