Improve ValidReferenceConstraint error messages by including bundle information

Created on 14 August 2025, about 21 hours ago

Problem/Motivation

Currently, entity reference validation error messages only display the entity type (e.g., "paragraph") when validation fails, making it difficult for content editors to understand what specific content type they were trying to reference.
For example, current error messages appear as "The referenced entity (paragraph: 123) does not exist."

These messages are not very helpful to content editors because:

  • Most users think in terms of paragraph type / component types (Call to Action, Carousel, etc.) rather than entity types
  • The entity type alone doesn't provide enough context about what type of paragraph is being referenced.
  • When working with multiple bundles of the same entity type, it's unclear which specific content type caused the validation error

For this specific case (paragraphs) the constraint validation happens when a specific paragraph type is no longer allowed to be placed on a specific content type when there are already existing paragraphs. And fixing this issue the content editor know exactly which paragraphs to remove.

Proposed Resolution

Enhance the ValidReferenceConstraint and ValidReferenceConstraintValidator classes to include bundle information in validation error messages, making them more user-friendly and informative.

Changes include:

1. Update constraint message templates to include a %bundle parameter:
2. Update validation logic to populate the %bundle parameter in error messages. As a result, error message should display:

  • This entity (paragraph - Call to Action: 123) cannot be referenced.
  • The referenced entity (paragraph - Call to Action: 123) does not exist.
📌 Task
Status

Active

Version

11.2 🔥

Component

entity system

Created by

🇧🇪Belgium bernardopaulino Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024