Issue #3374626 by lauriii, penyaskito, smustgrave, longwave: Comment type form title is confusing

merge-requests/4411/head
Dave Long 2023-07-19 15:37:18 +02:00
parent e983ee9d89
commit 95dcdb3f58
No known key found for this signature in database
GPG Key ID: ED52AE211E142771
3 changed files with 10 additions and 1 deletions

View File

@ -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:

View File

@ -74,6 +74,10 @@ class CommentTypeForm extends EntityForm {
$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'),

View File

@ -47,6 +47,7 @@ class CommentTypeTest extends CommentTestBase {
parent::setUp();
$this->drupalPlaceBlock('page_title_block');
$this->drupalPlaceBlock('system_breadcrumb_block');
$this->adminUser = $this->drupalCreateUser($this->permissions);
}
@ -67,6 +68,7 @@ class CommentTypeTest extends CommentTestBase {
// 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 @@ class CommentTypeTest extends CommentTestBase {
// 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);