Problem/Motivation
Found in #3048698: Content moderation layout builder integration fails when a node has an associated menu item
@alexpott
$entity->menuis added bymenu_ui_node_builder()which is added by a form alter -menu_ui_form_node_form_alter().But the constraint is added onmenu_ui_entity_type_build()level - so it is always present. Which makes the menu_ui not the most API friendly module. Is there an existing issue which covers this problem?
It seems weird to use Entity constraint for something that is only added via a form. I think if you were doing the same action say over JSON API you would make to POST/PATCH requests because this is actually 2 different content entities. In that case a entity level constraint makes no sense. So that would mean moving from using an entity constraint to I guess form validation function.
Proposed resolution
Determine if this validation should actually be a form validator
Remaining tasks
Determine best solution(or not change) and do it.
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3050199
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:
- 3050199-remove-entity-level
changes, plain diff MR !16155
Comments
Comment #11
smustgrave commentedTriaging my issue queue.
This still appears to be valid, since moved to hooks but still doing the same. Guess the thing to see is if it is on the form can it pick up the if it's a pending revision.
Comment #13
smustgrave commentedused claude slightly to help with the validator but relatively easy to convert :)
Comment #14
darvanenI've read the MR, looks good to me.
Comment #17
catchCommitted/pushed to main and 11.x, thanks!
Comment #19
darvanen@smustgrave do we publish the CR now?
Oh that's probably done on release, don't mind me
Comment #20
catchNo @darvenen that's a good question - we publish when things get committed. In this case I was debating with myself whether we needed a change record since individual validators are considered internal, but then forgot entirely. Since it's already written and looks fine, went ahead and published.
Comment #21
darvanenThanks for the update @catch, appreciate it :)