diff -u b/core/modules/system/src/Tests/Entity/EntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php b/core/modules/system/src/Tests/Entity/EntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php --- b/core/modules/system/src/Tests/Entity/EntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php @@ -97,8 +97,13 @@ 'field_reference[0][_weight]' => 0, 'field_reference[1][_weight]' => -1, ); + // Executing an ajax call is important before saving as it will trigger + // form state caching and so if for any reasons the form is rebuilt with + // the entity built based on the user submitted values then the correct + // mapping will break after the form builder maps over the new form the + // user submitted values based on the previous delta ordering. $this->drupalPostForm(NULL, $edit, t('Add another item')); - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm(NULL, [], t('Save')); $entity1 = $storage->load($entity1->id()); diff -u b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/EntityReferenceWithNameTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/EntityReferenceWithNameTestItem.php --- b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/EntityReferenceWithNameTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/EntityReferenceWithNameTestItem.php @@ -40,13 +40,6 @@ /** * {@inheritdoc} */ - public static function mainPropertyName() { - return NULL; - } - - /** - * {@inheritdoc} - */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); $schema['columns']['name'] = [