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.
Because field.html.twig
extends @stable
instead of @classy
, things like the visually-hidden
class aren't included. So when a site builder sets a label to be hidden or visually hidden, it doesn't work.
I can see this being a point of confusion -- a site builder hides a field label and it works in Bartik, but not in Basic. But I can also see the argument that Basic is trying to stay as lean as possible and the site builder should simply subtheme Basic and override the field template...
Comment | File | Size | Author |
---|---|---|---|
#8 | 2779743-8-visually-hidden.patch | 598 bytes | mikeker |
#8 | 2779743-7-8.interdiff.txt | 658 bytes | mikeker |
#7 | 2779743-7.patch | 594 bytes | mikeker |
#2 | 2779743-2.patch | 490 bytes | mikeker |
Comments
Comment #2
mikeker CreditAttribution: mikeker as a volunteer commentedAlso fixes the lack of a trailing newline in this file.
Comment #3
mikeker CreditAttribution: mikeker as a volunteer commentedAlways forget that... :)
Comment #4
joelpittetWhen/how does a site builder set that visually-hidden class? I don't think core has any drop-downs to that effect. If I'm building with Basic, i may want to use my own class names for these utility classes or borrowing from another framework
Comment #5
mikeker CreditAttribution: mikeker as a volunteer commentedIn
admin/structure/types/manage/<content_type>/display
a site builder can set display options on the field label. (Related, but out of scope for this issue, is that Basic doesn't handle the inline option either.) Classy then adds it infield.html.twig
:Comment #6
joelpittetThat seems more like a core bug/oversight but yeah in basic we use that utility class in a number of places already.
Maybe we can/should add that back to stable, since we do in in preprocess all over core anyway? If people don't have the class defined, most things won't work as expected and you can't easily change that class name across core :(
If you agree could you create that issue in core?
For Basic in the mean time, we should just add that class in ours, minus the
field__label
Comment #7
mikeker CreditAttribution: mikeker as a volunteer commentedAdded a core bug/followup: #2779919: Stable theme does not respect "visually hidden" field label display option.
Also updated Basic's field template to include the class with an @todo to remove it when the above issue is resolved.
Comment #8
mikeker CreditAttribution: mikeker as a volunteer commentedFinally read Drupal's Twig coding standards... :)
Comment #10
joelpittetThank you @mikeker, I've pushed that to the 8.x-1.x
Comment #12
FOXs-M CreditAttribution: FOXs-M as a volunteer and commentedyou Can Use this CSS Code: