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"
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | create-multiple-entities-complex-ief-test-2684511.patch | 3.99 KB | reekris |
Comments
Comment #2
reekris commentedAdded patch that tests creating a second entity reference.
Comment #3
reekris commentedComment #4
bojanz commentedThank you for isolating this bug with a test, this is just what we needed.
Comment #5
agoradesign commentedI 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
steps to reproduce
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:
Comment #6
henrijs.seso commentedGot around to re-roll #2653574: Unable to keep nested IEF data separate with multivalue fields.
Comment #7
sylvainm commentedI 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:
[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?
Comment #8
reekris commentedI have tested this again using the Drupal 8.1.8 and latest dev of IEF and I no longer have this issue. Closing!