diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
index faa6d0d..fcceaaa 100644
--- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
+++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
@@ -319,7 +319,7 @@ public function getPluginCollections() {
     $configurations = [];
     foreach ($this->getComponents() as $field_name => $configuration) {
       if (!empty($configuration['type']) && ($field_definition = $this->getFieldDefinition($field_name))) {
-        $configurations[$configuration['type']] = $configuration + [
+        $configurations[$field_name] = $configuration + [
           'field_definition' => $field_definition,
           'form_mode' => $this->mode,
         ];
diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
index 74b15b6..88b6bba 100644
--- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
+++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
@@ -290,7 +290,7 @@ public function getPluginCollections() {
     $configurations = [];
     foreach ($this->getComponents() as $field_name => $configuration) {
       if (!empty($configuration['type']) && ($field_definition = $this->getFieldDefinition($field_name))) {
-        $configurations[$configuration['type']] = $configuration + [
+        $configurations[$field_name] = $configuration + [
           'field_definition' => $field_definition,
           'view_mode' => $this->originalMode,
         ];
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDynamicDependenciesFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDynamicDependenciesFormatter.php
new file mode 100644
index 0000000..da9e272
--- /dev/null
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDynamicDependenciesFormatter.php
@@ -0,0 +1,75 @@
+<?php
+
+namespace Drupal\field_test\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Field\FormatterBase;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Plugin implementation of the 'field_test_dynamic_dependencies' formatter.
+ *
+ * @FieldFormatter(
+ *   id = "field_test_dynamic_dependencies",
+ *   label = @Translation("Dynamic dependencies test"),
+ *   field_types = {
+ *     "test_field",
+ *   },
+ *   weight = 0
+ * )
+ */
+class TestFieldDynamicDependenciesFormatter extends FormatterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultSettings() {
+    return [
+      'dependent_module' => NULL,
+    ] + parent::defaultSettings();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $element['dependent_module'] = [
+      '#title' => t('Module'),
+      '#type' => 'textfield',
+      '#default_value' => $this->getSetting('dependent_module'),
+    ];
+    return $element;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = [];
+    $summary[] = t('@setting: @value', ['@setting' => 'dependent_module', '@value' => $this->getSetting('dependent_module')]);
+    return $summary;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function viewElements(FieldItemListInterface $items, $langcode) {
+    $elements = [];
+
+    foreach ($items as $delta => $item) {
+      $elements[$delta] = ['#markup' => 'test'];
+    }
+
+    return $elements;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function calculateDependencies() {
+    $dependencies = parent::calculateDependencies();
+    $dependencies['module'][] = $this->getSetting('dependent_module');
+    return $dependencies;
+  }
+
+}
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetDynamicDependencies.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetDynamicDependencies.php
new file mode 100644
index 0000000..8fdccc7
--- /dev/null
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetDynamicDependencies.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Drupal\field_test\Plugin\Field\FieldWidget;
+
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\WidgetBase;
+use Drupal\Core\Form\FormStateInterface;
+use Symfony\Component\Validator\ConstraintViolationInterface;
+
+/**
+ * Plugin implementation of the 'test_field_widget_dynamic_dependencies' widget.
+ *
+ * @FieldWidget(
+ *   id = "test_field_widget_dynamic_dependencies",
+ *   label = @Translation("Test widget with dynamic dependencies"),
+ *   field_types = {
+ *     "test_field",
+ *   },
+ *   weight = 0
+ * )
+ */
+class TestFieldWidgetDynamicDependencies extends WidgetBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function defaultSettings() {
+    return [
+      'dependent_module' => NULL,
+    ] + parent::defaultSettings();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsForm(array $form, FormStateInterface $form_state) {
+    $element['dependent_module'] = [
+      '#title' => t('Module'),
+      '#type' => 'textfield',
+      '#default_value' => $this->getSetting('dependent_module'),
+    ];
+    return $element;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function settingsSummary() {
+    $summary = [];
+    $summary[] = t('@setting: @value', ['@setting' => 'dependent_module', '@value' => $this->getSetting('dependent_module')]);
+    return $summary;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
+    $element += [
+      '#type' => 'textfield',
+      '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : '',
+    ];
+    return ['value' => $element];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
+    return $element['value'];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function calculateDependencies() {
+    $dependencies = parent::calculateDependencies();
+    $dependencies['module'][] = $this->getSetting('dependent_module');
+    return $dependencies;
+  }
+
+}
diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTestTrait.php b/core/modules/field_ui/src/Tests/EntityDisplayTestTrait.php
new file mode 100644
index 0000000..f14e41a
--- /dev/null
+++ b/core/modules/field_ui/src/Tests/EntityDisplayTestTrait.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Drupal\field_ui\Tests;
+
+use Drupal\Core\Entity\Display\EntityDisplayInterface;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldStorageConfig;
+
+/**
+ * Provides common functionality for the Entity Display test classes.
+ */
+trait EntityDisplayTestTrait {
+
+  /**
+   * Adds default test fields to an entity.
+   *
+   * @param string[] $field_names
+   *   The field names.
+   * @param string $type
+   *   The type of field to create. Defaults to 'test_field'.
+   *
+   * @return array
+   *   An array of each field name mapped to an array containing the field
+   *   storage and field entities.
+   */
+  public function addDefaultTestFields($field_names, $type = 'test_field') {
+    $created = [];
+    foreach ($field_names as $field_name) {
+      $field_storage = FieldStorageConfig::create([
+        'field_name' => $field_name,
+        'entity_type' => 'entity_test',
+        'type' => $type,
+      ]);
+      $field_storage->save();
+      $field = FieldConfig::create([
+        'field_storage' => $field_storage,
+        'bundle' => 'entity_test',
+      ]);
+      $field->save();
+
+      $created[$field_name] = [
+        $field_storage,
+        $field,
+      ];
+    }
+
+    return $created;
+  }
+
+  /**
+   * Tests the dependencies of field components within an entity display object.
+   *
+   * @param array $dependent_fields
+   *   An array of field names to configure on the display, mapped to module
+   *   names to be used as dependencies.
+   * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
+   *   An entity display to configure and test.
+   * @param string $type
+   *   A formatter or widget ID to use that has dynamic dependencies.
+   */
+  protected function configureAndTestMultipleFieldComponentDependencies($dependent_fields, EntityDisplayInterface $display, $type) {
+    foreach ($dependent_fields as $field_name => $dependency) {
+      $display->setComponent($field_name, [
+        'type' => $type,
+        'weight' => 0,
+        'settings' => [
+          'dependent_module' => $dependency,
+        ],
+      ]);
+    }
+
+    $dependencies = $display->calculateDependencies()->getDependencies();
+    $this->assertArraySubset(array_values($dependent_fields), $dependencies['module']);
+  }
+
+}
diff --git a/core/modules/field_ui/src/Tests/ManageDisplayTest.php b/core/modules/field_ui/src/Tests/ManageDisplayTest.php
index 7ba011e..3ce547c 100644
--- a/core/modules/field_ui/src/Tests/ManageDisplayTest.php
+++ b/core/modules/field_ui/src/Tests/ManageDisplayTest.php
@@ -92,6 +92,7 @@ public function testFormatterUI() {
       'field_no_settings',
       'field_empty_test',
       'field_empty_setting',
+      'field_test_dynamic_dependencies',
       'field_test_default',
       'field_test_multiple',
       'field_test_with_prepare_view',
@@ -252,6 +253,7 @@ public function testWidgetUI() {
     }, $result);
     $expected_options = [
       'test_field_widget',
+      'test_field_widget_dynamic_dependencies',
       'test_field_widget_multiple',
     ];
     $this->assertEqual($options, $expected_options, 'The expected widget ordering is respected.');
@@ -313,8 +315,17 @@ public function testWidgetUI() {
     $this->drupalGet($manage_display);
 
     // Checks if the select elements contain the specified options.
-    $this->assertFieldSelectOptions('fields[field_test][type]', ['test_field_widget', 'test_field_widget_multiple']);
-    $this->assertFieldSelectOptions('fields[field_onewidgetfield][type]', ['test_field_widget']);
+    $expected_options_multiple = [
+      'test_field_widget',
+      'test_field_widget_dynamic_dependencies',
+      'test_field_widget_multiple',
+    ];
+    $this->assertFieldSelectOptions('fields[field_test][type]', $expected_options_multiple);
+    $expected_options_single = [
+      'test_field_widget',
+      'test_field_widget_dynamic_dependencies',
+    ];
+    $this->assertFieldSelectOptions('fields[field_onewidgetfield][type]', $expected_options_single);
 
     // Ensure that fields can be hidden directly by changing the region.
     $this->assertFieldByName('fields[field_test][region]', 'content');
diff --git a/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php b/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php
index 4a0e533..6308bad 100644
--- a/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php
@@ -13,6 +13,7 @@
 use Drupal\Core\Entity\Entity\EntityViewMode;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\field_ui\Tests\EntityDisplayTestTrait;
 use Drupal\node\Entity\NodeType;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\user\Entity\Role;
@@ -24,6 +25,8 @@
  */
 class EntityDisplayTest extends KernelTestBase {
 
+  use EntityDisplayTestTrait;
+
   /**
    * Modules to install.
    *
@@ -270,6 +273,27 @@ public function testFieldComponent() {
   }
 
   /**
+   * Tests the dependencies of field components within an entity display object.
+   */
+  public function testMultipleFieldComponentDependencies() {
+    // Set up two field components, each dependent on different arbitrary
+    // modules that should not already be dependencies otherwise.
+    $dependent_fields = [
+      'test_field' => 'action',
+      'test_field_2' => 'aggregator',
+    ];
+    $this->addDefaultTestFields(array_keys($dependent_fields));
+
+    // Now that the fields exist, set up the display.
+    $display = EntityViewDisplay::create([
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ]);
+    $this->configureAndTestMultipleFieldComponentDependencies($dependent_fields, $display, 'field_test_dynamic_dependencies');
+  }
+
+  /**
    * Tests the behavior of a field component for a base field.
    */
   public function testBaseFieldComponent() {
diff --git a/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php b/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php
index 09d2a20..b8fffac 100644
--- a/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php
@@ -6,6 +6,7 @@
 use Drupal\Core\Entity\Entity\EntityFormMode;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\field_ui\Tests\EntityDisplayTestTrait;
 use Drupal\KernelTests\KernelTestBase;
 
 /**
@@ -15,6 +16,8 @@
  */
 class EntityFormDisplayTest extends KernelTestBase {
 
+  use EntityDisplayTestTrait;
+
   /**
    * Modules to install.
    *
@@ -116,6 +119,26 @@ public function testFieldComponent() {
   }
 
   /**
+   * Tests the dependencies of field components within an entity display object.
+   */
+  public function testMultipleFieldComponentDependencies() {
+    // Set up two field components, each dependent on different arbitrary
+    // modules that should not already be dependencies otherwise.
+    $dependent_fields = [
+      'test_field' => 'action',
+      'test_field_2' => 'aggregator',
+    ];
+    $this->addDefaultTestFields(array_keys($dependent_fields));
+
+    $form_display = EntityFormDisplay::create([
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ]);
+    $this->configureAndTestMultipleFieldComponentDependencies($dependent_fields, $form_display, 'test_field_widget_dynamic_dependencies');
+  }
+
+  /**
    * Tests the behavior of a field component for a base field.
    */
   public function testBaseFieldComponent() {
