Issue #2744877 by katzilla, dernetzjaeger, biancajs, chipway, Gábor Hojtsy, catch, romainj, lucur, yoroy, kamalrajsahu21, dietmarg: Node add form shows 'create new revision' checkbox

8.3.x
webchick 2016-10-11 12:51:35 -07:00
parent 4f917488f1
commit 8dc87c91c3
3 changed files with 11 additions and 1 deletions

View File

@ -139,7 +139,7 @@ class NodeForm extends ContentEntityForm {
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $node->type->entity->isNewRevision(),
'#access' => $current_user->hasPermission('administer nodes'),
'#access' => $current_user->hasPermission('administer nodes') && !$node->isNew(),
'#group' => 'revision_information',
);

View File

@ -72,6 +72,12 @@ class NodeCreationTest extends NodeTestBase {
$this->drupalGet('node/' . $node->id());
$this->assertText($node->getOwner()->getUsername());
$this->assertText(format_date($node->getCreatedTime()));
// Check if the node revision checkbox is not rendered on node creation form.
$admin_user = $this->drupalCreateUser(array('administer nodes', 'create page content'));
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
$this->assertNoFieldById('edit-revision', NULL , 'The revision checkbox is not present.');
}
/**

View File

@ -111,6 +111,10 @@ class NodeEditFormTest extends NodeTestBase {
$first_node_version = node_revision_load($node->getRevisionId());
$second_node_version = node_revision_load($revised_node->getRevisionId());
$this->assertNotIdentical($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.');
// Check if the node revision checkbox is rendered on node edit form.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldById('edit-revision', NULL, 'The revision field is present.');
}
/**