Skip to content

Commit 415dae7

Browse files
committed
Issue #2995200 by Sam152, sjancich: Defaults for publishing options do not save when workflow is enabled
(cherry picked from commit d0a2440)
1 parent 9bbbf03 commit 415dae7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface
5454
*/
5555
public function enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
5656
// Force the revision checkbox on.
57-
$form['workflow']['options']['#value']['revision'] = 'revision';
57+
$form['workflow']['options']['revision']['#value'] = 'revision';
5858
$form['workflow']['options']['revision']['#disabled'] = TRUE;
5959
}
6060

modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,21 @@ public function testEnablingOnExistingContent() {
8888
$this->assertSession()->optionExists('moderation_state[0][state]', 'published');
8989
}
9090

91+
/**
92+
* @covers \Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter
93+
*/
94+
public function testEnforceRevisionsEntityFormAlter() {
95+
$this->drupalLogin($this->adminUser);
96+
$this->createContentTypeFromUi('Moderated', 'moderated');
97+
98+
// Ensure checkboxes in the 'workflow' section can be altered, even when
99+
// 'revision' is enforced and disabled.
100+
$this->drupalGet('admin/structure/types/manage/moderated');
101+
$this->drupalPostForm('admin/structure/types/manage/moderated', [
102+
'options[promote]' => TRUE,
103+
], 'Save content type');
104+
$this->drupalGet('admin/structure/types/manage/moderated');
105+
$this->assertSession()->checkboxChecked('options[promote]');
106+
}
107+
91108
}

0 commit comments

Comments
 (0)