Problem/Motivation

All fields have configurable description but not the title field. Also the title field will have configurable display once https://www.drupal.org/project/drupal/issues/2923701 gets merged. I think we should also provide a configurable description for the title field.

Proposed resolution

Create a new Content-Type Title Description field, which allows us to add a configurable help text/description for the title field.

Remaining tasks

  • Merge Code

Steps to reproduce/Testing steps

1. Goto admin/structure/types/manage/basic page

2. Observe that the title description field is absent.

3. Apply the patch.

4. Reload.

5. Observe that the title description field has been added.


User interface changes

New configuration Title Description field has been added for Content-Type

API changes

Data model changes

Release notes snippet

Comments

awm created an issue. See original summary.

awm’s picture

awm’s picture

Status: Active » Needs review
StatusFileSize
new296.2 KB
timmillwood’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

If adding this feature we'll needs tests.

awm’s picture

awm’s picture

Status: Needs work » Needs review

adding tests.

Status: Needs review » Needs work

The last submitted patch, 5: configurable_title_descrition-2999849-5.patch, failed testing. View results

awm’s picture

fixing the tests.

awm’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: configurable_title_descrition-2999849-7.patch, failed testing. View results

awm’s picture

awm’s picture

Status: Needs work » Needs review
timmillwood’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Looks good, thanks!

awm’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The test looks good.

+++ b/core/modules/node/src/NodeTypeForm.php
@@ -241,6 +247,10 @@ public function save(array $form, FormStateInterface $form_state) {
+    $title_description = $form_state->getValue('title_description');
+    if ($title_field->getDescription() != $title_description) {
+      $title_field->getConfig($type->id())->setDescription($title_description)->save();
+    }

This could result in two updates to configuration if you change both the label and the description. We should do something like:

    $title_description = $form_state->getValue('title_description');
    if ($title_field->getLabel() != $title_label || $title_field->getDescription() != $title_description) {
      $title_field->getConfig($type->id())
        ->setLabel($title_label)
        ->setDescription($title_description)
        ->save();
    }
awm’s picture

awm’s picture

Status: Needs work » Needs review

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dionsj’s picture

Patch #16 works fine for me with 9.0.2, I assume it's because it hasn't change much since 8.7.
I now get a description field just below where I can edit the name of the title field.
It also properly exports and imports to/from config.

Not sure about the tests as I haven't gotten my testing setup to work, so someone with more testing experience with Drupal should probably weigh in on that.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

abhijith s’s picture

Applied patch #16 .Now the title description field is available at edit section of a content type.
Including screenshot :
Before patch :

before1

before2

After patch:

after1

after 2

RTBC

abhijith s’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The patch doesn't apply to 9.2.x

anushrikumari’s picture

Assigned: Unassigned » anushrikumari
anushrikumari’s picture

Assigned: anushrikumari » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.86 KB

Rerolled patch #16 for 9.2.x, please review.

alexpott’s picture

Title: add configurable description to content type title field. » Add configurable description to content type title field.
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +Needs product manager review

I think there are a couple of things to consider from a UX perspective.

  • We can already set a title placeholder on the form display - while not the same as a description is this not enough?
  • This adds to the things to do on the node type configuration form and while the setting for the title label is here - is this really the correct place?
  • Relatedly since this is going to be a large box with an empty value many people will be tempted to fill in it and that might not be the best practice.

Tagging for a product manager review to get product/UX feedback.

Also the issue summary could do with an update to go into the usecase a little but more.

Also there is a module for this functionality already - https://www.drupal.org/project/node_title_help_text - with 2000 odd downloads so some people definitely need this functionality. And there is a help page on how to do this with form alters... https://www.drupal.org/node/1218528

alexpott’s picture

There's also history of removing a description #2350041: Remove node title field description

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

chike’s picture

We have people signing up to use our site and we found that unlike our inhouse trained content authors, the ones that signed up do not write SEO-friendly titles so we needed to leave some instruction under the field, then I found a need for this feature. I was a bit surprised this wasn't there all the while.

I applied #16 and it worked.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rakhi soni’s picture

Status: Needs work » Needs review
StatusFileSize
new2.77 KB
new65.08 KB
new57.66 KB

I have created a patch for version 9.5x, Now the title description field is available at edit section of a content type. Kindly review patch,,

ranjith_kumar_k_u’s picture

StatusFileSize
new2.76 KB
new845 bytes
rinku jacob 13’s picture

StatusFileSize
new394.41 KB
new303.91 KB

I have successfully applied patch #35 for 9.5.x. Adding screenshots for the reference

yashingole’s picture

Assigned: Unassigned » yashingole
yashingole’s picture

Assigned: yashingole » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new84.06 KB
new80.82 KB

Verified and tested patch #35 on Drupal 9.5.x-dev. Patch applied successfully and looks good to me.
Testing steps:
1. Goto admin/structure/types/manage/article
2. Observe that the title description field is absent.
3. Apply the patch.
4. Reload.
5. Observe that the title description field has been added.
Testing Result:
1. After applying the patch the title description field appears.
Can be move to RTBC

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Two years ago in #28, an issue summary update was asked for by a committer. That has yet to be done. And in #29 he questions whether this should be done at all because this was removed in #2350041: Remove node title field description.

And I see this is tagged for a product manager review, which has not happened.

There has been one comment for support of this feature request, aside from the author of this issue. Is that sufficient to do this?

Setting to NW for the issue summary update.

awm’s picture

I am not following how #2350041 is related to this. It has to do with the content type form.

This issue allows us to add a configurable help text/description for the title field.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rassoni’s picture

Status: Needs work » Needs review
StatusFileSize
new387.21 KB
new421.6 KB

Patch #35 Verified and tested locally on Drupal 10.1.x.
Patch applied successfully and looks good to me.


Testing steps:

1. Goto admin/structure/types/manage/basic page

2. Observe that the title description field is absent.

3. Apply the patch.

4. Reload.

5. Observe that the title description field has been added.


Testing Result:
 After applying the patch the title description field appears.


aziza_a’s picture

Checked the code, also title appears in the node as expected
RTBC + 1

smustgrave’s picture

Status: Needs review » Needs work

Still needs issue summary update.

sahil.goyal’s picture

Issue summary: View changes

Updating the IS.

sahil.goyal’s picture

Status: Needs work » Needs review
gábor hojtsy’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -Needs product manager review
StatusFileSize
new98.14 KB

The API already allows to configure this, it is not exposed on the UI though. I can see the use case of needing to give some guidance to the user about the title field. I also don't think this goes against #2350041: Remove node title field description, that removed a badly technical hard coded description, while this one does not add a new hardcoded description but exposes a feature to the user instead.

The field however is not added consistently with the rest of the elements. How is the field description presented on other field config pages? That would be best to replicate here.

danielveza’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new3.3 KB
new1.21 KB

Addressed #47.

Changed the field label to "Title field description"
Updated the description of the field based on the generic field description.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Thanks @Gábor Hojtsy for taking a look!

Appears to have a build failure

rassoni’s picture

Status: Needs work » Needs review
StatusFileSize
new3.31 KB
new932 bytes

Fixed Build failure.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Rassoni !

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 50: 2999849-50.patch, failed testing. View results

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jordik’s picture

StatusFileSize
new3.3 KB

Re-rolled patch from #50 to 10.2.x-dev.

acbramley’s picture

Status: Needs work » Closed (won't fix)

The Title field is a base field on Node.

Base fields can have their labels and descriptions overridden using the base_field_override config.

There is a module to expose UI to do this https://www.drupal.org/project/base_field_override_ui

Alternatively you can use drush to generate one for you, see https://www.previousnext.com.au/blog/overriding-base-field-labels-and-de...

An example of a title base field override for the page content type:
File: core.base_field_override.node.page.title.yml

langcode: en
status: true
dependencies:
  config:
    - node.type.page
id: node.page.title
field_name: title
entity_type: node
bundle: page
label: Title
description: 'My custom description'
required: true
translatable: true
default_value: {  }
default_value_callback: ''
settings: {  }
field_type: string