Having a custom validation constraint on an entity reference field using entity browser as form widget, I am trying to get the field light up in the form on validation violation. This is not working for me.
Using the following code in an entity validation constraint:
$this->context ->buildViolation($constraint->message, ) ->atPath('field_entity_reference') ->addViolation();
This works fine for fields that do not use the entity browser widget (the field gets marked red indicating an validation error). But for the entity browser widget the field is not marked in the form, though the validation itself is working correct. It seems to me this is related to the entity browser widget. There is this information about targeting specific properties in complex field widgets, which seems to address this matter. But I cannot seem to find a way to target the right property to make the field light up in the form. Entity Browser widget only have hidden form input elements and targeting does not seem to work on container or div fields as far as I can see, so maybe this is the reason this is not working?
Is there a possibility to have the entity browser widget light up in the form on validation violation?