Problem/Motivation
Follow-up to #2228763: Create a comment-type config entity and use that as comment bundles, require selection in field settings form. At the moment the comment form heading always says "Add new comment" on the form. If you have a specific comment type like "Greeting" you probably want it to say "Write greeting" instead.

Proposed resolution
This proposed resolution comes from the UX committee. See Comment 104 for details.
Add a Form heading field on the Comment field settings form of an entity. eg: Structure > Content Types > Article Manage fields > Comments or /admin/structure/types/manage/article/fields/node.article.comment.
Include the help text, "This text will be displayed as the heading of the comment form, if the theme supports it."
Place the Form heading field after the Comment field's Help text
Proposed resolution mockup

Remaining tasks
- ❌ Get Comment Module maintainer (larowlan, andypost) approval of the proposed resolution.
- ❌ Implement proposed resolution
- ❌ Add hook_update_n() implementation to update all existing comment types
- ❌ Write test coverage for merge request
- ❌ Write change record.
- ❌ Commit to Drupal core
- ❌ Celebrate the ability to now change the comment form heading through the Drupal admin UI. 🥳
User interface changes
New setting on the field.
API changes
Likely none. Config schema is expanded.
Data model changes
Config is expanded.
| Comment | File | Size | Author |
|---|
Issue fork drupal-2546116
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
andypostAlso we always get this link on node page
Comment #3
andypostComment #4
larowlanAgreed
Comment #5
mirom commentedComment #6
mirom commented@TODO: Translations
@GaborHojtsy - can you please explain `1) the list heading (defaults to "Comments")` little bit more, I think, this is field setting.
Comment #7
mirom commentedComment #9
mirom commentedFixed error from test.
Comment #10
mirom commentedComment #12
gábor hojtsy@miro: yeah I copied that text over mostly from @dixon's notes from the other issue. It is a field setting indeed, no need to work on that one :) Updated the summary.
Comment #13
mirom commentedError was in missing form_heading in Comment test suite even when it was failing on Search module test.
Comment #14
mirom commentedEnabling translation for Form heading property.
Comment #15
rteijeiro commentedThanks for the patch @mirom. Just spotted a few nits. Could you fix them, please?
Missing return description?
Comment #16
rteijeiro commentedSorry, this nit was missing in previous comment.
Missing spaces.
Comment #17
mirom commentedFixing whitespace errors.
Comment #18
mirom commentedComment #19
mirom commentedComment #20
rteijeiro commentedI think testbot will like the patch so it's RTBC for me. Checked with @mirom in Drupalaton :)
Great job!
Comment #21
dawehner@xano and @dawehner have been wondering whether instead of using a configuration we could pass along the context to the t() call depending on the comment type.
This then would allow you to translate it per context, or?
Comment #22
mirom commentedWhat should be context in this case? I see configuration more clear then context translation.
Comment #23
mirom commentedGabor says, the proposal in #21 is hack, so back to RTBC.
Comment #24
zserno commentedAlmost there, good job @mirom!
I found one small thing:
The static text 'Add new comment' should be wrapped in t().
Comment #25
mirom commentedThanks @zserno, fixed.
Comment #26
gábor hojtsyJust to clarify what @mirom said about my feedback, if all the field on comments are configurable on the field UI with their labels, and the label on the list of comments itself is configurable on the parent entity you attach them to, then putting the "Add new comment" string at an entirely different place to the interface translation would not work very well for usability. Also, it would not let you set up different text for different field instances, say if you have comments of type "Review" and comments of type "Greeting" then both need their own setting for "Add new review", "Add new greeting". While you could generate the t() context dynamically to allow for that, that is an even bigger hack, we don't do anything even remotely similar that I am aware at other places in core.
Comment #27
david.lukac commentedWorks for me with the latest patch. RTBC+1
D
Comment #28
mirom commentedComment #29
gábor hojtsyI see no reason to change history on this. It was worked on at Drupalaton 2015, lets keep it.
Comment #30
joelpittetThese can use the injected t(). aka: $this->t()
This likely needs to be pushed to 8.1.x since we've past RC. Assigning to webchick for product feedback.
Comment #31
joelpittetAlso this is not a bug, this a feature request. You can change that text through Translation in settings.php and by extending the template. This is a site builder feature request
Comment #32
Bojhan commentedWe shouldn't do these type of settings through the UI. Submissions is a completely different type of setting, as thats about supplying guidelines.
I am going to won't fix this, we don't do this through the UI no point in starting to do that now (especially not as a one-off).
Comment #33
gábor hojtsy@Bojhan: here is a simple way to explain the problem. I'd even say its at least a normal bug. If I can change the label of the listing of comments however I want but not how the input of them is presented, that is a problem. I can change all the labels and types of elements on the form however I want, I can make it a guest book or a review form but can never change the title of the form.
I also don't agree this is an RC deadline, we'll definitely need to move to 8.1 though. Such changes are not allowed in 8.0 anymore.
Comment #34
gábor hojtsy@joelpittet: the reason this is a bug is "translating" the "Add new comment" string to something else does not apply on a comment type level while the "Comments" label configuration does. Either way I don't think the category matters, given its not possible to do in Drupal 8.0.0 and both categories may be possible in 8.1.0.
Comment #35
Bojhan commented@Gábor How do we deal with this in other places? We don't offer this type of configurability for other types of UI facing elements that are module provided right? Only for fields. And this is not like a "field group" its a special legacy thing, from the old days.
I would argue that first setting is even worrisome. I saw your twitter message, and I think the whole point of our theme system is to go to the template files when you have to change things like that. We shouldn't have a UI for every user facing string (unless its translation), only the "flexible" parts.
At the very least we should have a standard, not one-offs.
Comment #36
Bojhan commentedWhat is broken here? Nothing. The fact that we have a one-off for one user interface element, does not necessarily constitute it also being there for the 2nd one. I feel like we discussed this particular feature before, and decided that the usecase for the 2nd one was ever so small.
This is adding a "thing" not about making it more consistent, because we don't have a pattern for this in core.
Comment #37
webchickTo me, the screenshot / description in #33 is definitely describing a bug. However, I agree with Bojhan that adding a UI setting for that particular piece of text feels very odd. As opposed to simply putting in the twig file:
<h2>Add new {{entity.label}}</h2>...or whatever.
That would solve the crux of this issue, without presenting new and confusing, one-off UI options.
Comment #38
Bojhan commentedOk ok :) Sorry for moving this about so much.
Comment #39
gábor hojtsy@Bojhan: I don't agree at all that the existing "Comments" configurability is a one-off. When I fill in the tags field the little "Tags" label shows up above the list of tags. When I add a field, its label shows up above the field value (in this screenshot a boolean field on whether its a feature or bug :P). Comments are a field. The "Comments" label shows up above the comments. Same as with tags or any other field I added. I think thats straightforward. It makes total sense and follows a pattern. HOWEVER, comments also emit another label with the same level header markup that is not configurable like the initial label. This kind of label indeed does not appear with any of the other core fields that I know. (That the "Comments" and "Add new comment" labels somehow show up on a different importance level / scale compared to the feature or bug field is not surprising, the tags field is also differently styled according to its role in the content).
@webchick: not sure using the type name of the comment type (I assume based on your suggestion) would suffice, the "Comments" label is independently configurable of the comment type. It would be odd to still not need to add a comment type for changing the "Comments" label but to need to add a comment type to be able to change the "Add new comment" label.
Comment #40
mirom commented@Gabor - what do we still need to fix in this issue? Should it go back to RTBC and be commited into 8.1.0?
Comment #41
andypostAs I said in #1 we also need to take care about node links (maybe separate issue) because now there's a bug - "Add new comment" link is always displayed (in teaser and full node view).
We should be able to configure node link too!
The only thing I'm not sure here is a usage of comment type to store this data.
Comment types are not about fields, they are about comment relation to commented entity!
So I think that field (or field storage) setting is most suitable for that because formatter and comment form are bound to the field not the comment type.
@mirom This could be accepted only as a part of 8.1 and later, and this needs
hook_update_n()implementation to update all existing comment types.I'd like to get rid of entity loading in preprocess
$this-t() should be used in forms
and there's no reason for empty() check - default value should be provided by comment type entity (as standard profile does)
Comment #42
larowlanAgree with @andypost on this - we want to make these (plugin based) formatter settings in #2377849: Simplify what CommentLinkBuilder is doing - consider removing a lot of the functionality so it would align with that.
Comment #43
wim leersDo we even need the ? Can't we simply remove it?
Comment #44
tkoleary commented@wim leers
IMO we do not need it. The "comment" label over the text area is sufficient.
While we're at it we really don't need "subject" either. :)
Comment #45
dawehnerIf you have multiple comment types on the page, which is a total usecase, dropping those labels makes the situation just worse.
Note, this small module was needed to make a page with two comment types usable. There are other places like the entity edit form, which has similar problems.
Comment #46
wim leersIndeed. But there's a separate issue for that already: #2312329: Hide the comment "subject" field by default.
But then you still have the "comment type" label?
We'd just change from this:
to this:
Comment #48
greg.b commentedIs this bug going to be fixed?
As it stands if you have 2+ comment forms on a page you cant label them? Such a simple thing is expected from a UI/UX perpective?
:)
Comment #50
balintcsaba commentedupdating issue summary based on review with YesCT @Drupalaton 2016
will try to do the remaining tasks tomorrow
Comment #51
balintcsaba commentedComment #54
gábor hojtsyI don't think keeping the old tag will do any harm(?)
Comment #55
balintcsaba commentedComment #57
balintcsaba commentedComment #58
andypostHere's some templates cleanup and
Fixed translatable config usage
This needs upgrade path
Comment #59
andypostComment #61
gábor hojtsyFix tags that @andypost inadvertently broke in #58.
Comment #63
mortona2k commentedI rerolled the patch, but I don't see the form header appearing.
Comment #66
anas_maw commentedPatch in #63 worked for me
Comment #68
andypostreroll + fix for tests
Comment #69
andypostCleaner default value
Comment #70
andypostAdd update hook & fix forum default config
Comment #71
andypostStill needs work to extend tests & upgrade path tests
Comment #73
nick hope commentedI installed the patch in #70 over Drupal 8.7.3 using Composer. When I then ran update.php I got a white screen with this error:
Fatal error: Cannot redeclare comment_update_8701() (previously declared in C:\Users\Nick\Sites\seelife\web\core\modules\comment\comment.install:255) in C:\Users\Nick\Sites\seelife\web\core\modules\comment\comment.install on line 274But the site still functioned and I was able to remove the patch and successfully run update.php.
Perhaps I need to reverse some of my site's comments configuration before applying the patch and running update.php, but I'm not sure what.
In the meantime I achieved it by commenting out the "Add new comment" line in a custom template, per Shawn Conn's answer here.
Comment #74
andypostYep, it should be post update hook instead of hook update
Comment #78
andypostComment #79
ankithashettyHi @andypost, rerolled the patch in #70. The changes made in
core/modules/comment/comment.installis not included in the rerolled patch. After the changes made in #3087644: Remove Drupal 8 updates up to and including 88**, I am not sure how to go about it...Comment #80
andypost@ankithashetty Thank you! the update hook needs re-work using
hook_post_update_NAME()ref https://www.drupal.org/node/2563673this hunk should go to
comment.post_update.phpas it changing config (doing upgrade)As example you could use
views_post_update_field_names_for_multivalue_fields()Comment #81
ankithashettyHey @andypost, thank you for all the references... I updated the patch as per your suggestions and fixed the custom failure errors in #79, kindly review.
Comment #82
andypostLooks great! It still needs additional tests for new functionality and test for upgrade hook
Comment #84
vakulrai commentedAdding a patch with test that will verify the functionality of new configurations and also made some changes in code/themes/bartik and core/theme/seven for comment field which were missed.
Comment #85
vakulrai commentedChanges invalid username issue in the previous patch and corrected unequal array in test.
Comment #86
vakulrai commentedUpdated coding standards.
Comment #87
vakulrai commentedComment #88
vakulrai commentedComment #91
andypostComment #92
andypostThe issue is a feature, but I see more like UX now
Comment #93
ravi.shankar commentedAdded reroll of patch #86 on Drupal 9.4.x.
Comment #94
yogeshmpawarUpdated patch will fix test failures & added an interdiff as well.
Comment #96
yogeshmpawarHope this will fix test failure.
Comment #101
catchMarked #2978209: Replace hard coded Add new comment in field--comment.html.twig as duplicate and moving credit over here.
Comment #102
rkollerI became aware of the issue when @andypost mentioned on the #bugsmash channel that there is the need of an ux review for a while. I've applied that patch to a Drupal 9.4.x install yesterday night and ran into a possible issue i am not quite sure if it is rooted in this patch, if it is a separate Olivero issue or if it is simply based on a configuration mistake of mine. I've agreed with @andypost to comment with the infos i've previously posted in the Slack chat. and when the point about Olivero (1.) is figured out i will propose the issue for the weekly UX meeting that more pair of eyes and perspectives take a look at the issue. I am not comfortable to remove a needs usability review tag on my own and anyway it is always better to have more people with different perspectives and background discuss the issue. about the points i've noticed.
1. I've used Claro as the admin theme and Olivero as the front end theme when setting up a comment type. For the
Form headingi've usedAdd a new thoughtwhile i've usedYour thoughtsas the label for the comment field in the article content type andYou add your thought in the comment fieldas the help text. I've then created an article and added a new comment calledmy very first commentwithtestin the body. but the visual representation is confusing:First comes the title
Your thoughts, then the new comment entry form missing theAdd a new thoughtform heading and then the list of comments. Also the help text isn't shown anywhere? ( I am not sure if that is the expected behaviour in regards of the help text).I've then switched with the same configuration to Bartik. The output looks like that now:
the comment entry form is correctly showing the set title and the order is different (in a way i'Ve expected). but the help text is missing there as well.
so is it possible that for Olivero the comment entry form title has to be added to the twig file as well? and is the positioning of the comment entry form differing between Olivero and Bartik? Meaning that in Bartik it is placed at the end while for olivero at the beginning? and as i said the help text is missing for both. But the description says
Instruction to present to the user below this field on the editing form, so i would expected it to be shown in the front end?2. The label for the introduced field
Form headingis a bit unspecific and general imho. If I wouldn't have had the context from the IS i would have had to make assumptions based on the default textAdd new comment. But it would be probably helpful to have a clear title and perhaps explanatory description as well?I am not a native speaker therefor hesitant to make any definite word smithy suggestions. But something in the direction of
New comment entry form heading. That would be clearer but also too lengthy unfortunately.3. And the last point is about the placement of the field. When i've applied the patch i've searched in the comment field settings (
/admin/structure/types/manage/article/fields/node.article.comment) the screenshots in the IS were about. also it is the place where the title of the comment section is set . therefor i thought i would expect the field to be found there. that the user is able to set the title for the add new comment form in the same context on the same page.took me quite a while, and i already thought even though the patch successfully applied that something is wrong with it and it failed to provide the functionality it wants to provide, until i've realised the field is located on the edit page of a comment type
/admin/structure/comment/manage/comment?destination=/admin/structure/comment. I am not sure if it would be possible and also make sense from a developer point of view to move the field to the comment field page? or what others think about that? at least for me personally it was quite confusing and an unexpected location and placement of the field.Comment #103
mherchelYeah, it looks like we change that around in our field--comment.html.twig. I'd be fine going back to the default, but we should talk to the UX group about it and then maybe put together a design for the small "Add new comment" jump link that appears by default.
Hopefully this answers all the Olivero related questions here. Let me know if it doesn't.
Thanks for working on this!
Comment #104
rkollerI've presented the issue on yesterdays usability meeting (2022-05-06). The list of attendees was @AaronMcHale, @benjifisher, @bnjmnm, @ckrina, @shaal, @worldlinemine and me. The results are as follows:
1. The label of the form field alone is a bit vague. The group agreed to add the following description to the field to provide more clarity (the wording is based on the style of the other descriptions) :
This text will be displayed as the heading of the comment form, if the theme supports it.. The second part of the sentence (after the comma) was chosen and added because it isn't sure if a frontend theme is supporting the display of theform headingfield at all. And it might be confusing for the users if they add content to theform headingfield and the entered text couldn't be found in the front end theme afterwards (like it is currently the case with Olivero).2. The point I've made in #102.2 that the label
form headingmight be adjusted was discussed as well but it was decided against it. The combination of the label, the placeholder textAdd new commentand the newly introduced descriptionThis text will be displayed as the heading of the comment form, if the theme supports it.provides enough context and clarity. So the label could remain as is.3. The group then agreed if it would be technically possible to move the

form headingfield from the comment types page over to the comment field page for a content type. So theform headingis configurable along with the display label for the comment field. We haven't talked or agreed on the exact position on the comment field page. I just did a quick mockup by adding the form heading component in devtools to the page:Addendum: While writing the comment @benjifisher commented the screenshot i've posted alongside in the #ux channel and agreed that the position of the
form headingfield is good: "near the other text fields and above the other form elements"4. When checking the latest patch in #96 the variable
form_headingis added to thefield--comment.html.twigin Bartik and wrapped in ah2. At the momentfield--comment.html.twigin Olivero doesn't contain the same addition of theform_headingvariable wrapped in ah2. That way the effect of the patch isn't visible to users who have selected Olivero as their default theme, which could create or lead into confusion. So it would be good to add it for Olivero as well.@mherchel i've noticed that i have forgot to bring up the order of the comment components in yesterdays call. sorry about that. :( but i think that detail isn't directly related to this issue. therefor we could revisit in one of the next ux meeting calls and create a follow up issue in case the rest of the group considers it an issue as well? You think that would be ok?
Thank you for all the work on the issue, and definitely a good and useful addition to Core. :)
Comment #107
aaronmchaleUsability review was provided in comment #104, removing tag.
Comment #109
cedeweyI've updated the task description based on the UX committee's recommendations.
As the Comment Module's maintainers, @larowlan or @andypost can you review the proposed resolution and state whether you approve of the proposed resolution? And if not, list out your concerns and ideally an alternative proposal?
Comment #110
cedeweyComment #113
andypostComment #114
jacobupal commentedUpdated the issue branch to make it merge-able again since conflicts arising from https://www.drupal.org/project/drupal/issues/3396165