Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The comment.module emits an anhor tag above the comments, so links can be pointed to there, and it is given an id="comment". But since there is a textarea named "comment" in the output of the comment_form() function, and that label tags are connected with ids to form items, another HTML tag gets the id="comment". XHTML does not allow for two elements to have the same ID. The IDs should be unique.
Comment | File | Size | Author |
---|---|---|---|
#6 | duplicate_id_comment_reply_form.patch | 559 bytes | erikhopp |
Comments
Comment #1
Gábor HojtsyAdditionaly, the default implementation of comment_form() also emits an "a" tag with id="comment" (even if there are comments above, and there is an "a" tag with id="comment" before them), so if you enable the instant comment form on node pages, you get three HTML tags with id="comment".
Comment #2
(not verified) CreditAttribution: commentedThanks for heads up.
Easiest thing for me to do personally was just change the ID to a class.
then I can have separate stylings based in .comment anchors or .comment text areas and whatnot.
Comment #3
Gábor HojtsyThe comment id is important to get an anchor to link to with comment links, so changing it to a class is not a good option.
Comment #4
TheLibrarian CreditAttribution: TheLibrarian commentedI don't seem to have this problem. Maybe your theme is redefining some of the theme_comment hooks?
Comment #5
JonBob CreditAttribution: JonBob commentedI can confirm this to be a problem, even with the default themes. The comment reply page has duplicate id="comment" attributes.
Comment #6
erikhopp CreditAttribution: erikhopp commentedi changed the second id to comment-form as, thats what it is.
the patch does not seem to change the appearance of phptemplate and probably does not change anything else, but you might want to test it first.
one-line patch attached.
erik
Comment #7
Dries CreditAttribution: Dries commentedCommitted this patch to HEAD and DRUPAL-4-4. Thanks Erik.
Comment #8
(not verified) CreditAttribution: commented