Opened 10 years ago

Closed 10 years ago

Last modified 10 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: master
Severity: normal Keywords: newforms
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 10 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 10 years ago by Chris Beaven

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 Changed 10 years ago by Adrian Holovaty

Component: Core frameworkdjango.newforms

comment:3 Changed 10 years ago by Adrian Holovaty

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

comment:4 Changed 10 years ago by Adrian Holovaty

Care to write up a patch? :)

Changed 10 years ago by Chris Beaven

Attachment: newforms_label.patch added

comment:5 Changed 10 years ago by Chris Beaven

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

comment:6 Changed 10 years ago by Chris Beaven

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 Changed 10 years ago by Adrian Holovaty

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 Changed 10 years ago by Adrian Holovaty

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

comment:9 Changed 10 years ago by Adrian Holovaty

(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