Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3064 closed defect (fixed)

[patch] newforms should use <label>

Reported by: John D'Agostino <john.dagostino@…> Owned by: adrian
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 SmileyChris 8 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by SmileyChris

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 8 years ago by adrian

  • Component changed from Core framework to django.newforms

comment:3 Changed 8 years ago by adrian

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

comment:4 Changed 8 years ago by adrian

Care to write up a patch? :)

Changed 8 years ago by SmileyChris

comment:5 Changed 8 years ago by SmileyChris

  • Summary changed from newforms should use <label> to [patch] newforms should use <label>

comment:6 Changed 8 years ago by SmileyChris

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 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(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 8 years ago by adrian

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

comment:9 Changed 8 years ago by adrian

(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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.