Make the moderation control form an entity form so that it validates entities before save

Created on 2 February 2017, almost 8 years ago
Updated 15 August 2024, 3 months ago

Problem/Motivation

Currently the moderation form that appears on top of draft entities for the purposes of moderation is a custom form. This form doesn't attempt to validate entities before saving them, reducing the overall utility of entity validations.

Proposed resolution

  • Fix this by moving the form into an entity form.
  • For rendering, create a transient view mode, as was done with the layout builder form.

Before:

After:

Remaining tasks

Review + commit.

User interface changes

Minor label changes.

API changes

Render array changes, with a change record.

Data model changes

None.

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Content moderationΒ  β†’

Last updated 1 day ago

  • Maintained by
  • πŸ‡¦πŸ‡ΊAustralia @Sam152
Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

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

    The major change should have a special release note written to summarize the importance of the change. See Write a release note for an 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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Closed πŸ› Content moderation revision log should be a textarea as on node edit forms Closed: duplicate as a duplicate

  • πŸ‡ΊπŸ‡ΈUnited States scotwith1t Birmingham, AL

    FYI, patch in #81 still applies cleanly to 10.0.9 and works as expected.

  • πŸ‡΅πŸ‡ΉPortugal joao.ramos.costa

    Unless otherwise noted and tests fail, here is an attempted reroll from #81 to D10.3.

  • πŸ‡§πŸ‡ͺBelgium msnassar

    The log message field might have a different name e.g. in media it is revision_log_message. Meaning either we get the log message field name using $this->entity->getEntityType()->getRevisionMetadataKey('revision_log_message'); or in entity-moderation-form.html.twig we just output the form elements using original entity form keys. However the later doesn't ensure existing form alter will continue to work.

    Here are new patches for D10.2 and D10.3 that remove the piece of code that shuffles the form elements around into their respective original keys and instead use the keys from the entity form itself in the template entity-moderation-form.html.twig... However, I am not sure how I could handle the BC here.

    Screenshot with the new patch:

  • πŸ‡΅πŸ‡ΉPortugal joao.ramos.costa

    Yes, @msnassar. Worked like a charm.

  • πŸ‡¨πŸ‡­Switzerland boromino

    Thanks for this patch. Works with Drupal 10.3.1 and also fixes another inconsistency:

    Changing the workflow state on latest revision tab, stores the timestamp of the former revision in node_field_revision and the timestamp of the actual change only in node_revision whereas both timestamps are identical and correspond with the time of the actual change, if the revision has been saved on the add/edit form and the entity implements \Drupal\Core\Entity\EntityChangedInterface.

Production build 0.71.5 2024