Problem/Motivation
(This came up in #2860097: Ensure that content translations can be moderated independently.)
Using hook_entity_prepare_form(), instead of relying on routes (and its load_latest_revision flag) to integrate Content Moderation with entity forms. This would have the following advantages over the current approach:
- it would support nested entity forms
- it would support multiple unrelated entity forms on the same route
OTOH it would have the drawback of making things less explicit.
Proposed resolution
Use hook_entity_prepare_form().
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2940907-3.patch | 6.46 KB | sam152 |
Comments
Comment #2
wim leersI did some research into this exactly one week ago. I talked to Content Moderation maintainer Tim Millwood.
I asked him:
He answered:
So how did this come to be?
My guess is that it could lead to some form alters behaving incorrectly (because based on the route definition, it should be the default revision, not the latest), but that’s just a hypothetical.
Zero mentions of "prepare" in #2865616: Add an option for EntityConverter to load the latest entity revision and fix all entity forms to use this option..
It's fine if there is a good reason for this to be implemented this way, but that reason is not obvious and comes with trade-offs, so it should be documented.
Comment #3
sam152 commentedI think the answer is indeed: we've always done it that way! With regards to the converter issue, I suppose the idea was moving the existing utility of the CM converter to core for other modules to use, I don't think that precludes us from stepping back and asking if it's the right approach for entity forms specifically.
This shouldn't be too hard to prototype. If we're sticking with the approach of core being responsible for this (which I'm still convinced should be the case)
EntityForm::initinvokesentity_prepare_formright after it callsprepareEntity, so loading the latest revision in there should do nicely.It's probably better to postpone discussing if CM should implement the hook or if core should load it for us, behind #2940575: Document the scope and purpose of pending revisions.
Comment #15
geek-merlinIs this still an issue? I guess it's outdated.
Comment #16
amateescu commentedThis was fixed in #2942907: Entity system does not provide an API for retrieving an entity variant that is safe for editing.