[development] Form element wrapper IDs
Martin Stadler
martin at siarp.de
Sat Jan 2 10:54:06 UTC 2010
Hi!
I stumbled upon the issue that there are no form element wrapper IDs
for radios and checkboxes without the #title or #description
attributes in D6 (http://drupal.org/node/215301). I need an ID to hide
the label with CSS for accessability. I checked how this is in D7 and
it seems to me that there are no wrapper IDs at all, only classes
which are in the case of radios and checkboxes not unique (I know that
classes are not supposed to be unique, that's why I want IDs):
<div class="form-item form-type-radios form-item-myformelem">
<label>My Form Element </label>
<div class="form-radios">
<div class="form-item form-type-radio form-item-myformelem">
<input type="radio" id="edit-myformelem-0" name="myformelem"
value="0" checked="checked" class="form-radio" />
<label class="option" for="edit-myformelem-0">Option 1 </label>
</div>
<div class="form-item form-type-radio form-item-myformelem">
<input type="radio" id="edit-myformelem-1" name="myformelem"
value="1" class="form-radio" />
<label class="option" for="edit-myformelem-1">Option 2 </label>
</div>
</div>
</div>
In modern browsers this may be ok but in IE6 I can't access the
wrapper div nor the top label directly.
If #title is omitted in the PHP form api code then we get
<div class="form-radios">
<div class="form-item form-type-radio form-item-myformelem2">
<input type="radio" id="edit-myformelem2-0" name="myformelem2"
value="0" checked="checked" class="form-radio" />
<label class="option" for="edit-myformelem2-0">Option 1 </label>
</div>
<div class="form-item form-type-radio form-item-myformelem2">
<input type="radio" id="edit-myformelem2-1" name="myformelem2"
value="1" class="form-radio" />
<label class="option" for="edit-myformelem2-1">Option 2 </label>
</div>
</div>
How can I style this individual wrapper now? I may have multiple
radios in my form.
Actually the problem is the same in D6 and D7. In D6 we have wrapper
IDs but not for radios and checkboxes and in D7 we have kind of unique
classes for the wrappers but these are not unique for radios and
checkboxes. Why were the wrapper IDs removed in D7? Pseudo-unique
classes seem strange to me. How can we have a unique accessor for
wrappers for radios and checkboxes? Can we add the wrapper IDs for
them in D6? Why were these wrapper IDs unset in D6?
Martin
More information about the development
mailing list