Skip to main content
NikoFischer.com

Main navigation

  • Home
  • About
    • Recommended Youtube Channels
    • Life Rules
    • Podcast
  • 50-Day Challenge
  • Impressum
Sprachumschalter
  • English

Breadcrumb

  1. Home

How to Change the Title of a Drupal Form (Drupal 9 & 10)

Drupal user registration form

If you want to change the title of a form, whether it's the title of the registration form or a node add form, you have two options:

Here's an example of how to change the title of the registration form:

1. Use the hook_preprocess_page_title

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_MYMODULE_preprocess_page_title(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'registration_link.register') {
    $variables['title'] = t('New Title');
  }
}

2. Utilize the hook_preprocess_html

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_MYMODULE_preprocess_html(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'registration_link.register') {
    $variables['head_title']['title'] = t('New Title');
  }
}

These two approaches allow you to customize the title of a Drupal form of your choice. Replace 'New Title' with the desired title text you want to display.

Tags

  • Drupal

Comments

About text formats

Restricted HTML

  • Allowed HTML tags: <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Related articles

Drupal 9.1 REST: Post and patch requests are rejected
CORS is not meant to secure an API endpoint
Upgrading Drupal 9 to Drupal 10 Using Composer
The Future of Drupal: A Comprehensive Analysis and Forecast
The 5 Best Drupal Modules for Bloggers in 2024
Ihre Anmeldung konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.
Ihre Anmeldung war erfolgreich.

Newsletter

Join a growing community of friendly readers. From time to time I share my thoughts about rational thinking, productivity and life.

Nikolai Fischer

✌ Hi, I'm Niko
Entrepreneur, developer & podcaster

Contact me:

  • E-Mail
  • Phone
  • LinkedIn
RSS feed