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.
For accessibility and convenience, the variable names in the Devel Variable Editor table should be wrapped in LABEL
s referring to their checkboxes. I'm a FAPI newbie, but I'd be happy to write a patch if someone would point me in the right direction. :)
Comment | File | Size | Author |
---|---|---|---|
#12 | devel-variable-labels.jpg | 60.91 KB | jvogt |
#11 | devel-variable-labels-1257584-11.patch | 993 bytes | jacob.embree |
Comments
Comment #1
salvisI agree, but I'm not sure it's possible, because they are in two separate columns. Have you looked this up on w3c and tried it out on a static HTML page?
Comment #2
Everett Zufelt CreditAttribution: Everett Zufelt commentedIn drupal 7 you can do:
#title = foo
#title_display = invisible || attribute (attribute for checkbox / radio only)
if set to invisible it will create
<label class="element-invisible" for="id-of-form-element">#title</label><input .... />
The .element-invisible class in D7 hides content from all except for screen-reader users. for attribute it will set the title attribute of the form input field as #title. Both of these work for accessibility.Ideally the label in the one column would be wrapped in a label element with the for attribute set to the id of the input element, but this is tricky, if not near impossible, in D7 FAPI.
In D6 you can just set #attributes = array('title' => #title,)
This should work.
Comment #3
TravisCarden CreditAttribution: TravisCarden commentedSure, salvis. A
LABEL
that can't be wrapped around a form element can be manually attached to it using thefor
attribute. e.g.:The part that I don't know how to do is to get the ID of the checkbox in the PHP (in the
while
loop around line 1238 of devel.module, specifically).Comment #4
salvisMaybe #post_render can help?
Oh, and D7/8 needs to go first...
Comment #5
Everett Zufelt CreditAttribution: Everett Zufelt commentedIf you point me to the correct, or presumed correct, place in the module I can take a quick peak and give some more feedback. I recall doing something similar with Core a couple of years ago.
Comment #6
Everett Zufelt CreditAttribution: Everett Zufelt commentedI took a look at devel_variable_form() in devel.pages.inc (8.x-1.x).
I then took a look at theme_tableselect(). I definitely recognize where the problem lies and filed #1258278: tableselect documentation in FAPI reference incomplete.
As I comment in the above issue, I will take a look to see how this is addressed in Core, as I know that checkboxs in tableselect forms have a title attribute set.
Comment #7
mgiffordSubscribing...
Comment #8
salvisThanks for looking into this!
Comment #9
Everett Zufelt CreditAttribution: Everett Zufelt commented@mgifford found this function in the other issue. I haven't checked if the #title property is only available in D7+, so take a look at the function for D6 just in case.
From form_process_tableselect():
'@title' => $element['#options'][$key]['title']['data']['#title'],
Comment #10
willzyx CreditAttribution: willzyx commentedDevel Variable Editor no longer exists n 8.x branch so moving to 7.x
Comment #11
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedHere it is in an after_build callback.
Comment #12
jvogt CreditAttribution: jvogt as a volunteer commentedThis patch worked as intended for me. Screenshot of the HTML attached.
Comment #14
salvisVery nice--thanks, jacob.embree and zorya!