On Mon, Aug 15, 2011 at 2:51 PM, wayne <wayne.tuxro...@gmail.com> wrote:

> I have noticed that when I use one of the "shortcut" template
> rendering calls (eg, as_ul) that the resulting form gets a label that
> is the same as the first item in a selection list--in this case, a
> RadioSelect.  For example, I get something akin to the following:
>
> [snip]
> Note that the form itself has the same identifier (id_1_MembershipForm-
> membership_level_0) as the first RadioSelect option.
>

I found your post confusing; I think you have used the word "form" in
several places where you really mean "field". Yes, the rendering of a form
field with choices as a radio input, by default, sets the overall label for
the field to be "for" the first choice in the list. A set of radio buttons
is not a single input, rather it is one html input for each choice. Each
radio input has an individual label with text equal to the choice. In
addition the Django form field has a label with text that defaults to the
name of the field. There is no way in HTML to say a label is "for" a set of
inputs, so this overall field label is set to be for the first input element
in the list of choices


>  This breaks
> accessibility for us (viewable at wave.webaim.org), and html
> validation (at validator.w3.org).
>

Breaks accessibility how? Clicking on the overall field label is the same as
clicking on the label for the first choice...is that breaking accessibility?
I can see how that behavior might be non-obvious but I don't see that it is
"broken".

What HTML validation errors are you getting, and what HTML doctype are you
using? In a brief test of HTML from a page that uses a Django radio select
field rendered in this way I am not getting any validation errors from
validator.w3.org.

I am well aware that I can take
> care of this by writing my own html in the template, and that as_p,
> as_ul, and as_table are really just for simple forms and/or
> prototyping.  However, what I'm wondering is if there is a
> "better" (read: solution that doesn't require me writing the html)
> solution or a specific class/method to override that will correct this
> behavior.  Or am I missing something else about this entirely?
>

You haven't said what you would like to see instead. If you want no label at
all for the overall field you can pass an empty string as label on the form
field definition. If you do want the text of the label, but you don't want
it to be wrapped in the html label tag, then maybe you want a custom
RadioFieldRenderer. This is possible but not currently documented, ticket
#15244 has a patch with some how-to doc that you may find useful.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to