The Dynamic Entity Reference widgets render a target_type selector next to the main target_id autocomplete element.
When the target_id element is required, hidden, disabled, or conditionally controlled through #states, the target_type selector does not inherit the same form state. This can lead to inconsistent UX and validation feedback.
For example, a required Dynamic Entity Reference field can show the required marker and validation on target_id, while the target_type selector remains visually optional.
Proposed fix: Add an #after_build callback to the DER widget wrapper and synchronize selected form state properties from target_id to target_type:

  • #required
  • #access
  • #disabled
  • #states

This keeps both parts of the composite widget aligned, including cases where other form alters add state to target_id after the widget’s formElement() method runs.

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

gugalamaciek created an issue. See original summary.

gugalamaciek’s picture

Assigned: gugalamaciek » Unassigned
Status: Active » Needs review