Issue #2995200 by Sam152, sjancich: Defaults for publishing options do not save when workflow is enabled

8.7.x
Alex Pott 2019-02-22 11:15:24 +00:00
parent 185513febe
commit d0a2440cff
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 18 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class NodeModerationHandler extends ModerationHandler {
*/
public function enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
// Force the revision checkbox on.
$form['workflow']['options']['#value']['revision'] = 'revision';
$form['workflow']['options']['revision']['#value'] = 'revision';
$form['workflow']['options']['revision']['#disabled'] = TRUE;
}

View File

@ -88,4 +88,21 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
$this->assertSession()->optionExists('moderation_state[0][state]', 'published');
}
/**
* @covers \Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter
*/
public function testEnforceRevisionsEntityFormAlter() {
$this->drupalLogin($this->adminUser);
$this->createContentTypeFromUi('Moderated', 'moderated');
// Ensure checkboxes in the 'workflow' section can be altered, even when
// 'revision' is enforced and disabled.
$this->drupalGet('admin/structure/types/manage/moderated');
$this->drupalPostForm('admin/structure/types/manage/moderated', [
'options[promote]' => TRUE,
], 'Save content type');
$this->drupalGet('admin/structure/types/manage/moderated');
$this->assertSession()->checkboxChecked('options[promote]');
}
}