diff --git a/core/modules/contact/contact.pages.inc b/core/modules/contact/contact.pages.inc index 491bb30..c9ab5c8 100644 --- a/core/modules/contact/contact.pages.inc +++ b/core/modules/contact/contact.pages.inc @@ -8,6 +8,7 @@ use Drupal\contact\Entity\Category; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Drupal\Component\Utility\String; /** * Page callback: Presents the site-wide contact form. @@ -53,7 +54,9 @@ function contact_site_page(Category $category = NULL) { $message = entity_create('contact_message', array( 'category' => $category->id(), )); - return \Drupal::entityManager()->getForm($message); + $form = \Drupal::entityManager()->getForm($message); + $form['#title'] = String::checkPlain($category->label()); + return $form; } /** @@ -79,13 +82,13 @@ function contact_personal_page($recipient) { contact_flood_control(); } - drupal_set_title(t('Contact @username', array('@username' => user_format_name($recipient))), PASS_THROUGH); - $message = entity_create('contact_message', array( 'recipient' => $recipient, 'category' => 'personal', )); - return \Drupal::entityManager()->getForm($message); + $form = \Drupal::entityManager()->getForm($message); + $form['#title'] = t('Contact @username', array('@username' => user_format_name($recipient))); + return $form; } /** diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php index e974ec6..acd9e7d 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php @@ -94,6 +94,8 @@ function testPersonalContactAccess() { $this->drupalLogin($this->web_user); $this->drupalGet('user/' . $this->admin_user->id() . '/contact'); $this->assertResponse(200); + // Check the page title is properly displayed. + $this->assertRaw(t('Contact @username', array('@username' => user_format_name($this->admin_user)))); // Test denied access to admin user's own contact form. $this->drupalLogout(); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 8a9e210..1c69c2e 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -126,6 +126,9 @@ function testSiteWideContact() { $this->assertEqual($config['reply'], $reply); $this->assertNotEqual($id, \Drupal::config('contact.settings')->get('default_category')); $this->assertRaw(t('Category %label has been updated.', array('%label' => $label))); + // Ensure the label is displayed on the contact page for this category. + $this->drupalGet('contact/' . $id); + $this->assertText($label); // Reset the category back to be the default category. \Drupal::config('contact.settings')->set('default_category', $id)->save();