For accessibility and convenience, the variable names in the Devel Variable Editor table should be wrapped in LABELs 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. :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

salvis’s picture

I 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?

Everett Zufelt’s picture

In 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.

TravisCarden’s picture

Sure, salvis. A LABEL that can't be wrapped around a form element can be manually attached to it using the for attribute. e.g.:

<input type="checkbox" id="some-id" />
               <label for="some-id">Test</label>

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).

salvis’s picture

Maybe #post_render can help?

Oh, and D7/8 needs to go first...

Everett Zufelt’s picture

Version: 6.x-1.x-dev » 8.x-1.x-dev

If 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.

Everett Zufelt’s picture

I 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.

mgifford’s picture

Subscribing...

salvis’s picture

Thanks for looking into this!

Everett Zufelt’s picture

@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'],

willzyx’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes

Devel Variable Editor no longer exists n 8.x branch so moving to 7.x

jacob.embree’s picture

Here it is in an after_build callback.

jvogt’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
60.91 KB

This patch worked as intended for me. Screenshot of the HTML attached.

  • salvis committed 4edd3d4 on 7.x-1.x
    Issue #1257584 by jacob.embree, zorya: Devel Variable Editor: Wrap...
salvis’s picture

Status: Reviewed & tested by the community » Fixed

Very nice--thanks, jacob.embree and zorya!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.