Problem/Motivation
There are no constraints for the parent base field in core, but if a contrib/custom module adds a constraint to the base field, the violations will be removed in validation of the content entity form.
Parent base field does not have a component in the form display, but is added directly in the form, so the field will be missing from:ContentEntityForm::getEditedFieldNames
So those fields violations will be removed: ContentEntityForm::216
$violations->filterByFields(array_diff(array_keys($entity->getFieldDefinitions()), $edited_fields));
This means that the violations are removed, and the entity is saved although it shouldn't.
Proposed resolution
1. Override getEditedFieldNames
and add the field
2. Override flagViolations
to flag the correct form element
as described in the docblocks in ContentEntityForm.
Remaining tasks
Solve the bug.
User interface changes
No.
API changes
MenuLinkContentForm will override 2 methods. However, MenuLinkContentForm is marked internal, so we should be fine.
Data model changes
Release notes snippet