21 votes
Accepted

What is the difference between the Workbench and Workflow modules?

Workbench gives you an intuitive and friendly user interface to control content (nodes)transitions on a previously defined states on a role based access control means that every transition to the node ...
Mohammed Gomma's user avatar
12 votes
Accepted

How can I programatically change the (D8 core) workflow state of an entity with Content Moderation?

A great example could be found in Content Moderation module's code. $entity->set('moderation_state', $new_state); if ($entity instanceof RevisionLogInterface) { $entity->setRevisionLogMessage(...
Dmytro Danylevskyi's user avatar
6 votes
Accepted

What is the "default revision"?

So that means it will become the active revision shown to users. So if a revision is published its got to become the default revision as it will be shown as the page content for normal users When you ...
Leigh's user avatar
  • 2,944
5 votes
Accepted

How to change the content moderation state in a custom submit handler?

To change the moderation state you need first to get the entity: $entity = $form_state->getFormObject()->getEntity(); and then change the state: $entity->set('moderation_state', 'submitted'...
Adrian Cid Almaguer's user avatar
5 votes

How can I let users create new drafts for *existing* content?

We use the Workflow module and have found it to be pretty stable, and we use it exactly as you have described, to allow a content person to edit content, then for an admin to approve it. Configuring ...
Kdev's user avatar
  • 51
4 votes
Accepted

How can I change the published state of a node before it is saved with hook_entity_presave()?

I have tested with hook_entity_presave() and setPublished(0) and setPublished(FALSE) both worked. So the issue is somewhere else. If you have workbench moderation installed, you may need to set it ...
oknate's user avatar
  • 14.2k
4 votes

Content approval by roles

Workbench is a great way to do this if you are OK with installing another module. Workbench allows you to add moderation states. By default it gives you 'draft', 'published', and 'needs review'. (...
Caroline Casals's user avatar
4 votes

How to change the content moderation state in a custom submit handler?

I had to solve this problem too, and found two ways to do it: Option 1: Set the widget type to value, and set the default value to submitted. I also removed the current state message showing on the ...
andy-morgan's user avatar
4 votes

get the content moderation value on node update

Getting the version of the entity meant getting the last revision and allow to get the correct value function my_hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) { if ($entity->...
Matoeil's user avatar
  • 3,409
3 votes
Accepted

How to create media image entities like an image field?

Sounds like exactly the use case Inline Entity Form was built for: Provides a widget for inline management (creation, modification, removal) of referenced entities.
Clive's user avatar
  • 167k
3 votes
Accepted

Getting the workflow associated to a node type

Workflows are configuration entities so you can load them using their id: $workflow = $this->entityTypeManager->getStorage('workflow')->load('workflow_machine_name'); Or "query" them using ...
d70rr3s's user avatar
  • 919
3 votes

How do you programmatically include an entity type to a workflow?

You need the addEntityTypeAndBundle method from ContentModerationInterface A static way to implement it looks like: $workflow = \Drupal::entityManager()->getStorage('workflow')->load([...
cchen's user avatar
  • 757
2 votes
Accepted

Creating a workflow

You can setup complete workflow using these modules with webform: Webform Workflow This is a Drupal 7 module which allows assigning workflow 'states' to webform submissions. Users can be ...
Adeel Nawaz's user avatar
  • 3,211
2 votes

Creating a workflow

You can use hooks to change almost anything in the webform like additional submit handlers can be handled, validation can be done, elements can be added, etc. Refer the already existing answers, it ...
developer's user avatar
  • 440
2 votes
Accepted

How can I let users create new drafts for *existing* content?

Option 1: Revisioning A possible alternative could be the Revisioning module. Some more details (from its project page): ... a module for the configuration of workflows to create, moderate and ...
Pierre.Vriens's user avatar
2 votes

What is the difference between the Workbench and Workflow modules?

Both these modules are basically used for the same purpose but their architecture is what differentiates them. Cant exactly compare which one is better out of them but based on the requirement i ...
Amey Mudras's user avatar
2 votes
Accepted

The right form to work with pages

You don't need to create a content type for each different page. You need some tools for site building. I think in your case Paragraphs will be the best solution. You can for example create different ...
4uk4's user avatar
  • 99.3k
2 votes
Accepted

What might cause the unexpected workflow state changes after executing a rule?

Option 1 Rules is great, but sometimes also tough to debug if things don't work as you'd expect. There are typically 2 ways of debugging, as further detailed below. Rules Evaluation Log Within the ...
Pierre.Vriens's user avatar
2 votes

How can I programatically change the (D8 core) workflow state of an entity with Content Moderation?

I'm not heavily using D8 yet, but in D7's Workbench Moderation module nodes had a moderation_state field that was Draft or Published. Transitions in D7 were typically for User Role workflows whereas ...
tenken's user avatar
  • 18.4k
2 votes
Accepted

Reestablishing development workflow with GIT after doing it wrong

Commit the changes on the live site to the master git branch and then branch off this to create a develop branch. The master branch should mirror live and development takes place on individual ...
Colin Shipton's user avatar
2 votes
Accepted

execute action on workflow transition

You can use hook_ENTITY_TYPE_update to achieve this. /** * Implements hook_ENTITY_TYPE_update(). */ function mymodule_node_update(Drupal\Core\Entity\EntityInterface $entity) { //Get the ...
Jay Chand's user avatar
  • 425
2 votes

Is the Workflow module a Symfony component?

No, the Workflow module is not a Symfony component. As for what you found, the first list are the Drupal core dependencies, which include its dependencies from Symfony components. Under the replace ...
apaderno's user avatar
  • 97.4k
2 votes

Content Moderation: Editorial workflow not installed and broken/missing handler on the moderated content view

The guys over at Drupal's Slack channel pointed me in the right direction. I added detailed troubleshooting infos to the Content Moderation Guide. If you enable Content Moderation (drush en ...
electric.larry's user avatar
2 votes

How do I get the submitted moderation state of a custom block?

all most there try the following // Get the current entity. $entity = $form_state->getFormObject()->getEntity(); $moderation_state = $entity->get('moderation_state')->getString(); // Do ...
taggartJ's user avatar
  • 2,132
2 votes
Accepted

Is possible to add a field to content moderation's states?

Out of the box? No. You will have to create a custom module that adds such boolean field to your content types or entity types. Via hook_form_alter you can use #ajax with #access OR alternatively use #...
No Sssweat's user avatar
  • 31.2k
2 votes
Accepted

Auto assign term to node from term field from user

Can easily create a custom module with the following use hook_entity_presave ... https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_presave/9.4....
taggartJ's user avatar
  • 2,132
1 vote
Accepted

Link to create a node, save it, and then go to the edit page

I think the simplest way is to save the node right after you've created it in a custom version of NodeController::add(): public function add(NodeTypeInterface $node_type) { $node = $this->...
4uk4's user avatar
  • 99.3k
1 vote
Accepted

How can I automatically assign users to a node based on a taxonomy?

I would do something like this: RFP question is a custom content type. RFP question includes a term reference/entity reference to a taxonomy vocabulary called Category. Category has an entity ...
Patrick Kenny's user avatar
1 vote

Content Moderation: how to make a button to move between states?

Based on the code from Neograph734, this is the code I actually used (tested and working): function MYMODULE_form_node_CONTENTTYPE_form_alter(&$form, FormStateInterface $form_state, $form_id) { ...
Patrick Kenny's user avatar
1 vote
Accepted

Content Moderation: how to make a button to move between states?

I think you should be able to do something like this. (But I did not test). The first code block adds an additional submit button and gives it a custom submit handler. (Button specific submit ...
Neograph734's user avatar
  • 8,409

Only top scored, non community-wiki answers of a minimum length are eligible