Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Step to replicate:
1. Installed the module
2. Create Vocabulary (ej: Test 1)
3. Create Reference Value pair Entity with Test 1 (Create if does not exist)
4. Add new Reference Value pair Data.
5. Go to the Vocabulary and delete the terms
6. Go to the entity to add new Reference Value pair Data and you can see the values there without the reference term.
Comment | File | Size | Author |
---|---|---|---|
#3 | reference_value_pair-2834024-3-invalid-reference.patch | 9.11 KB | miiimooo |
data term deleted.png | 2.83 KB | rivedav | |
data created.png | 3.45 KB | rivedav |
Comments
Comment #2
miiimoooYes this is a big problem. Related issues are #2827177: Delete references to deleted entities Drupal 8 and #1368386: Delete references to deleted entities with the added complexity of what should happen with the value.
See this comment for possible approaches https://www.drupal.org/node/1368386#comment-11834828
For entity references in D7 this deletion issue is handled by some additional contrib modules. Maybe it's too big to handle it here. In my opinion there should be some setting to at least display the value when the entity reference is invalid or empty.
Comment #3
miiimoooAttached a first go at this: It adds two elements to the field formatter settings:
* Display invalid reference
* Invalid reference label
Depending on what you chose you can set the formatters to display just the value or a custom label like "(None)" or "(Deleted)".
For developers: if you have your own custom formatter and it's based EntityReferenceFormatterBase like the two formatters that come with the module then you can use the new ReferenceValueFormatterBase as a drop-in replacement to get this extra functionality (but also needs some code adjustments as now entity can be NULL - the label is set in the _label property).