- 🇫🇮Finland aleksip Finland
I came across this as well, and am able to reproduce it, and it does seem like a bug:
- Vanilla Drupal 10.1.x install with Inline Entity Form 1.0-rc15.
- Add
field_articles
entity reference field topage
. - Add a constraint validator checking that
field_tags
is not empty in referenced articles. - Verify that validator works with core widget.
- Set simple IEF widget and remove an existing tag in the inline form, validator does not work on save.
- Add core patch from https://www.drupal.org/project/drupal/issues/2826717 🐛 EntityReferenceFieldItemList::referencedEntities might not return up-to-date entity objects Needs work .
- Now simple IEF widget works.
- Change to compex IEF widget, does not work with or without the core patch.
Other possibly related IEF issues:
- https://www.drupal.org/project/inline_entity_form/issues/2858803 ✨ Include Entity Object When Updating The Existing Entity Postponed: needs info
- https://www.drupal.org/project/inline_entity_form/issues/2830829 🐛 Entities are not updated during buildEntity() phase Needs work
- 🇫🇮Finland aleksip Finland
After some more testing it seems that the constraint validator does work with the complex IEF widget if the core patch is applied and the IEF widget's Update button is clicked before saving the parent form.
If the parent form is saved with an opened and modified complex IEF form, the validator does not get an entity with the modified values. But since modifications to the referenced entity are saved even without clicking Update, this seems to be a bug in the complex widget.
Something that is probably good to mention here as well is that the core bug is replicated in Entity Reference Revisions, so if that module is used for the reference field a similar patch should be used from https://www.drupal.org/project/entity_reference_revisions/issues/3098924 🐛 referencedEntities() causes data loss Needs review .