Problem/Motivation

While working on #2800875: Autocreate for Entity Reference selection handlers that extend ViewsSelection and #3632280: Make entity reference validation messages consistent and accurate, I noticed entity autocomplete duplicates reference validation already provided by ValidReferenceConstraintValidator.

Proposed resolution

Use ValidReferenceConstraint to validate the autocomplete element's parsed references as a field item list, passing in its already configured selection handler.

The added options let contrib and custom autocomplete and autocreate implementations reuse the constraint with their already configured selection handler. No host entity is required.

Existing messages and reporting order are preserved. Validating the target entities' own constraints remains outside this issue.

API changes

Add optional handler and allowNewEntities constraint options. Existing constructor argument positions remain unchanged.

User interface changes

None.

Data model changes

None.

Remaining tasks

Review and run Core CI.

Issue fork drupal-3632357

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pancho created an issue. See original summary.

pancho’s picture

Status: Active » Needs review

Guess we're ready for review.