summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal
diff options
context:
space:
mode:
Diffstat (limited to 'core/lib/Drupal')
-rw-r--r--core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
index 183e428..c282427 100644
--- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
+++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
@@ -65,6 +65,10 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
* The entity for which the form is being built.
* @param string $form_mode
* The form mode.
+ * @param bool $default_fallback
+ * (optional) Whether the default display should be used to initialize the
+ * form display in case the specified display does not exist. Defaults to
+ * TRUE.
*
* @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface
* The display object that should be used to build the entity form.
@@ -72,7 +76,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
* @see entity_get_form_display()
* @see hook_entity_form_display_alter()
*/
- public static function collectRenderDisplay(FieldableEntityInterface $entity, $form_mode) {
+ public static function collectRenderDisplay(FieldableEntityInterface $entity, $form_mode, $default_fallback = TRUE) {
$entity_type = $entity->getEntityTypeId();
$bundle = $entity->bundle();
@@ -82,7 +86,9 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
if ($form_mode != 'default') {
$candidate_ids[] = $entity_type . '.' . $bundle . '.' . $form_mode;
}
- $candidate_ids[] = $entity_type . '.' . $bundle . '.default';
+ if ($default_fallback) {
+ $candidate_ids[] = $entity_type . '.' . $bundle . '.default';
+ }
$results = \Drupal::entityQuery('entity_form_display')
->condition('id', $candidate_ids)
->condition('status', TRUE)
@@ -101,7 +107,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
$display = $storage->create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
- 'mode' => $form_mode,
+ 'mode' => $default_fallback ? $form_mode : static::CUSTOM_MODE,
'status' => TRUE,
]);
}