diff --git a/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php b/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php index eeac1ce..de050bd 100644 --- a/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php +++ b/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php @@ -63,14 +63,16 @@ public function testPageAccess() { // Access the node form before moderation is enabled, the publication state // should now be visible. $this->drupalGet('node/add/moderated_content'); - $this->assertSession()->fieldExists('Published'); + $status_field = $this->assertSession()->fieldExists('Published'); + $this->assertFalse($status_field->hasAttribute('disabled')); // Now enable the workflow. $this->enableModerationThroughUi('moderated_content', 'editorial'); - // Access that the status field is no longer visible. + // Access that the status field is no longer enabled. $this->drupalGet('node/add/moderated_content'); - $this->assertSession()->fieldNotExists('Published'); + $this->assertSession()->elementAttributeExists('css', '[data-drupal-selector="edit-status-value"]', 'disabled'); + $this->assertSession()->elementAttributeContains('css', '[data-drupal-selector="edit-status-value"]', 'disabled', 'disabled'); // Create a node to test with. $this->drupalPostForm(NULL, [ diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 007b7c6..16c92a2 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -111,6 +111,12 @@ public function form(array $form, FormStateInterface $form_state) { ]; $form['status']['#group'] = 'footer'; + // Show a disabled Published checkbox if user has no access. + if (!$form['status']['#access']) { + $form['status']['#access'] = TRUE; + $form['status']['#disabled'] = TRUE; + } + // Node author information for administrators. $form['author'] = [ '#type' => 'details',