Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#3064 closed defect (fixed)

[patch] newforms should use <label>

Reported by: John D'Agostino <john.dagostino@…> Owned by: Adrian Holovaty
Component: Forms Version: dev
Severity: normal Keywords: newforms
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

newforms should use <label> tags form field names for two reasons

  1. Accessibility Reasons
  2. Semantic Markup (for those CSS purists)

See:
http://www.cita.uiuc.edu/html-best-practices/nav/forms.php
http://simon.incutio.com/archive/2003/02/11/labelElements
http://www.netmechanic.com/news/vol7/accessibility_no2.htm

Problems that would be faced are that currently auto_id is off by default - to use label tags newforms would require it to be on.

Any thoughts?

Attachments (1)

newforms_label.patch (4.2 KB ) - added by Chris Beaven 18 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Chris Beaven, 18 years ago

I agree (as I suggested in my #3023 patch which attempted to do way too much at once)

My suggestion is that label tags are only applied to fields which have an ID (either manual or auto). auto_id still isn't required this way.

comment:2 by Adrian Holovaty, 18 years ago

Component: Core frameworkdjango.newforms

comment:3 by Adrian Holovaty, 18 years ago

SmileyChris -- that suggestion sounds good. Let's apply the <label> only to fields that have an ID (either manual or auto).

comment:4 by Adrian Holovaty, 18 years ago

Care to write up a patch? :)

by Chris Beaven, 18 years ago

Attachment: newforms_label.patch added

comment:5 by Chris Beaven, 18 years ago

Summary: newforms should use <label>[patch] newforms should use <label>

comment:6 by Chris Beaven, 18 years ago

In widgets.py, class RadioInput(object) has uses a <label> tag. I haven't changed that or really looked closely at it, so you might want to make sure that's ok.

Since I did the patch, I better leave you something to do. ;)

comment:7 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

(In [4130]) Fixed #3064 -- newforms: Added <label> support through BoundField.label_tag() method. Also added BoundField.verbose_name and added/updated unit tests. Thanks, SmileyChris

comment:8 by Adrian Holovaty, 18 years ago

For the record, I still haven't deal with the RadioInput conflict...

comment:9 by Adrian Holovaty, 18 years ago

(In [4131]) newforms: The <input> tags in a RadioSelect now each have a distinct ID. Also, this plays nicely with auto_id and <label>s for Form.as_table() and Form.as_ul(). Refs #3064

Note: See TracTickets for help on using tickets.
Back to Top