This is issue has previously been discussed in #2653574: Unable to keep nested IEF data separate with multivalue fields..

How to reproduce:

1. Fresh install of Drupal 8.0.3 on a server running PHP 7.
2. install IEF latest dev version
3. Create an entity reference field on an Article node that references Article nodes and set form display to "Inline entity form - Complex"
4. Add a new Article
5. In the edit form add a new referenced Article node with the title "Test 1" and create it
6. Add another Article, call it "Test 2" and create it.

Expected Result:

- First item is called "Test 1" and second item "Test 2"

Actual result:

- Both items are called "Test 1"

Adding a third item will overwrite the first one again so that the reference table will look like this:

1. "Test 3"
2. "Test 2"
3. "Test 3"

Comments

reekris created an issue. See original summary.

reekris’s picture

Added patch that tests creating a second entity reference.

reekris’s picture

Status: Active » Needs review
bojanz’s picture

Thank you for isolating this bug with a test, this is just what we needed.

agoradesign’s picture

I have also experienced this problem and also another one, which I guess has the same root cause. So I'll document it here instead of opening a new issue. The original description refers to the situation, where you create more than one entity at once. I have found a similar situation, where the bug happens, when you only add one new entity to an already existing parent, with an already existing entity reference.

Setup

  • Drupal 8.0.5
  • IEF 1.0-alpha5
  • node type with entity reference field using IEF complex widget, field not required
  • a custom entity type can be referenced, having a title, an textarea field (formatted text), a string field, an image field with alt and title text
  • a node including one reference is already saved

steps to reproduce

  1. Edit the node, that already contains one reference
  2. Add another entity, filling in the same values as for the first one (use case: create dummy content)
  3. create the entity and save the node

expected result

The newly created entity gets saved and the node references both entities.

actual result

The new entity won't get saved at all, but the node references the first entity twice.

playing with different values

As stated above, this only happened, when I created dummy content, where every field got the same value. As soon as there's a minimal difference in at least one field, there's no problem at all - with one exception. The image file itself "does not count" as difference. But as soon as you add a different alt text, and leave all other fields the same, you won't have a problem at all.

Here's a table to show my different trials and the results. 'eq' means, that the value of this field of the new entity equals the value of the same field of the already existing entity, 'neq' => not equals:

title textarea textfield img src img alt img title result
eq eq eq (empty) neq eq eq (empty) FAIL
neq eq eq (empty) neq eq eq (empty) ok
eq neq eq (empty) neq eq eq (empty) ok
eq eq eq (empty) neq neq eq (empty) ok
henrijs.seso’s picture

sylvainm’s picture

I have this bug too, but with php version 5.6 and 7.0.
Tried with latest dev: 81fbe89d6822da13c5263f78f5e6042381a6f432

It seems the values are overriden only on the 2 first references entities: the third or fourth one keeps its values while others are changed.

Exact PHP versions are:

  • 5.6.21-9+donate.sury.org~trusty+1
  • 7.0.6-13+donate.sury.org~trusty+1

[Edit] : sorry for the noise, it was my mistake: I add the two sames entities referenced.
I don't have this bug anymore with last dev version, do you?

reekris’s picture

Status: Needs review » Closed (cannot reproduce)

I have tested this again using the Drupal 8.1.8 and latest dev of IEF and I no longer have this issue. Closing!