Problem/Motivation
On my way to DrupalCamp Karachi I was having a look at EntityReferenceFieldItemList for to find a fix for #2389605: DER's "autocreate" feature is mostly broken (and untested). I realized EntityReferenceFieldItemList::referencedEntities(), EntityReferenceFieldItemList::processDefaultValue() and EntityReferenceFieldItemList::defaultValuesFormSubmit() are specific to ER. We need DynamicEntityReferenceFieldItemList for DER. It will also fix #2365297: Can't set field default value which is a wrong fix anyway.
Proposed resolution
Create DynamicEntityReferenceFieldItemList for DER.
Remaining tasks
Complete the patch.
Add tests.
Review.
User interface changes
None
API changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | der-list.2.patch | 1.7 KB | larowlan |
| #12 | 2405009-DER-FieldItemList-12.patch | 13.24 KB | jibran |
| #12 | interdiff.txt | 5.56 KB | jibran |
Comments
Comment #1
larowlanaaaah
Comment #2
jibranDon't you think we need tests for that? Should we create an interface for DERFieldItemList? How does Drupal know that now it has to user DERFieldItemList instead of ERFieldItemList?
Comment #3
jibran+ * list_class = "\Drupal\dynamic_entity_reference\DynamicEntityReferenceFieldItemList",Comment #4
jibranNow with patch.
Comment #6
jibranI think we can remove the hunk introduced in #2365297: Can't set field default value.
Comment #8
jibranThis will fix the test.
Comment #10
jibranWith a proper fix.
Comment #11
jibranDynamicEntityReferenceFieldItemList::referencedEntities()see #2073661: Add a EntityReferenceField::referencedEntities() method for tests.ValidReferenceConstraintinDynamicEntityReferenceItemwhich usesValidReferenceConstraintValidatorandValidReferenceConstraintValidator::validateis specific to ER field.ReferenceAccessConstraintValidatorif yes then it is also specific to ER.Comment #12
jibranAdded tests for point 1. I think we can fix this issue. Going to move 2 and 3 to new issue I have a failing test for 2.
Comment #13
larowlanThanks @jibran great job
Comment #14
jibranCreated #2405607: Fix DER constraint validation for #11.2 and #11.3
Comment #15
berdirLooks good to me as well.
Comment #16
jibranThanks.
Comment #18
larowlan$item is out of scope here
Comment #20
jibranThis wrong. We can't use id's again.
Comment #21
larowlanwhoops
Comment #22
jibranCool
Comment #23
larowlan