Parent field violations are removed in the content entity form

Created on 17 October 2019, over 5 years ago
Updated 23 May 2023, almost 2 years ago

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

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Menu link content 

Last updated 4 days ago

Created by

🇸🇪Sweden johnwebdev

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024