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.
In HTML, ids must be unique.
Because field groups have / can have id attributes, in the case a field group is outputted multiple times in a single HTML page, the resulting HTML is invalid.
Unfortunately fixing this would break existing CSS selectors used by sites / themes, so maybe this one should be fixed in 2.x?
Comment | File | Size | Author |
---|---|---|---|
#1 | div_duplicate_ids.patch | 831 bytes | rreiss |
Comments
Comment #1
rreiss CreditAttribution: rreiss commentedI've created a patch to solve this issue using
drupal_html_id
.Please review.
Comment #2
Pere OrgaJust checked and the issue cannot be reproduced anymore on dev. Is this a duplicate?
Comment #3
rreiss CreditAttribution: rreiss commentedYou're right - the validation errors are gone when using the dev version.
The "fix" on the dev version was to completely remove the field group's id attribute, I don't think this is the right decision.
What about upgrading from V1.3 to a newer version? CSS styles may be broken for those who used the IDs.
The Drupal way is to use drupal_html_id to prevent those issues.
BTW - The patch from my first comment is for 7.x-1.3 .
Comment #4
Pere OrgaNote that your patch would break existing CSS selectors too
Comment #5
rreiss CreditAttribution: rreiss commentedMine will only break on the case when someone used the ID selector to style multiple field group with the same ID, instead of using the class attribute.
In my opinion, if someone doesn't follow HTML and CSS standards it's his/her fault.
Comment #6
nils.destoop CreditAttribution: nils.destoop commentedThis is indeed a duplicate of #2037731.
Gonna release a new version today. The fix will then be also available in a stable release.
Comment #8
nils.destoop CreditAttribution: nils.destoop commented