diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index e92e8daf797ccfd9dfa5fdefb703060a8cc59799..da7e917880a4ca7e442308f2f5d91cbcf51c018f 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -135,7 +135,7 @@ entity.comment_type.edit_form: path: '/admin/structure/comment/manage/{comment_type}' defaults: _entity_form: 'comment_type.edit' - _title: 'Edit' + _title_callback: '\Drupal\Core\Entity\Controller\EntityController::title' requirements: _entity_access: 'comment_type.update' options: diff --git a/core/modules/comment/src/CommentTypeForm.php b/core/modules/comment/src/CommentTypeForm.php index 37b1bf973b6283480930842707b69ef78981641c..3ab6a6892458d535d2935ddaa26027ebcdb68832 100644 --- a/core/modules/comment/src/CommentTypeForm.php +++ b/core/modules/comment/src/CommentTypeForm.php @@ -74,6 +74,10 @@ public function form(array $form, FormStateInterface $form_state) { $comment_type = $this->entity; + if ($this->operation === 'edit') { + $form['#title'] = $this->t('Edit %label comment type', ['%label' => $comment_type->label()]); + } + $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index 1fd9be1fa57de56a0a7eebd4fcc3a0b1f6ff4242..2e22b9e4ad7d567ed2bf169d2f840fbf0a28b6b3 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -47,6 +47,7 @@ protected function setUp(): void { parent::setUp(); $this->drupalPlaceBlock('page_title_block'); + $this->drupalPlaceBlock('system_breadcrumb_block'); $this->adminUser = $this->drupalCreateUser($this->permissions); } @@ -67,6 +68,7 @@ public function testCommentTypeCreation() { // Ensure that the new comment type admin page can be accessed. $this->drupalGet('admin/structure/comment/manage/' . $type->id()); $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->elementTextEquals('css', 'h1', "Edit {$comment_type->label()} comment type"); // Create a comment type via the user interface. $edit = [ @@ -81,6 +83,9 @@ public function testCommentTypeCreation() { // Asserts that form submit redirects to the expected manage fields page. $this->assertSession()->addressEquals('admin/structure/comment/manage/' . $edit['id'] . '/fields'); + // Asserts that the comment type is visible in breadcrumb. + $this->assertTrue($this->assertSession()->elementExists('css', 'nav[role="navigation"]')->hasLink('title for foo')); + $comment_type = CommentType::load('foo'); $this->assertInstanceOf(CommentType::class, $comment_type);