Work with Moderation to determine moderation state (Submit for Approval)

Created on 10 August 2022, about 3 years ago
Updated 6 August 2025, 6 days ago

Problem/Motivation

Require on Publish is only checking if the entity is published and does not account for possible moderation states. For example, we'd like editors to be able to save a draft without filling in all required fields and RoP works well to allow this but it also allows the user to "Submit as Draft" because this is not considered published content. Since we need all required fields to be filled in when submitting for approval this is a roadblock for us.

Steps to reproduce

  1. Enable core Moderation module.
  2. Mark fields on content type as "Required on Publish".
  3. Fill in the node but leave some RoP fields empty.
  4. Submit the node as a draft and it submits as expected.
  5. Now submit the node as "Submit for Approval" and the node still submits instead of failing validation.

Proposed resolution

Add an alter hook to the validate function to allow other modules to modify the "$is_published" variable.

Patch attached.

Example hook_alter();

function MY_MODULE_require_on_publish_is_published_alter(&$is_published, $entity, $operation){

  switch ($operation){
    case 'Submit for Approval':
      $is_published = TRUE;
      break;
  }
}

Remaining tasks

✨ Feature request
Status

Active

Version

1.6

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States 3cwebdev

Live updates comments and jobs are added and updated live.
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