Re: Creating accessible forms with CGI

BAYLISS, Andrew wrote:
> I am at present building a website using the CGI.pm module, the pages are at
> present not passing the Bobby test due to each form element not having label
> tags. Every HTML method can be generated via its corresponding method in
> CGI.pm, but I am unable to find a method to print <Label for=""></label> or
> methods for fieldset and legend tags.

CGI.pm is handy for many things but is not without its limitations, 
especially when what you need is accessible (X)HTML.  This module is NOT 
a full implementation of the (X)HTML specification so if there's an 
accessibility method you can't find easily, it's probably not there.  I 
use CGI.pm for creating headers and getting variables from the query 
string; I find myself having to write my own code more and more to 
provide the accessibility features that I need.

CGI.pm is written by Lincoln D. Stein; the obvious fix is to get him 
interested in fixing this. However, Lincoln is doubtless very busy and 
shares this tool out of the kindness of his heart, so I would be loath 
to hastle him about feature requests.  I don't know whether there is a 
CGI.pm mailing list - I couldn't find one with a quick look at Google - 
but I think that this, or a Perl list would be an appropriate forum to 
raise the issue of CGI.pm and accessibility.  Some kind soul who isn't 
afraid to get their hands dirty with Perl modules may even contribute 
the changes that we are looking for.

Quick and dirty solution to get you out of trouble, assuming that you've 
got all of your field names in an array called @fooary:

foreach my $fname (@fooary)
{
	print "<label for='$fname'>$fname</label>
		<input type='text' name='$fname' id='$fname' />";
}

I have a routine that I've written that can create the HTML for whole 
forms, based on MySQL database table schemas; if this would be any help, 
contact me off-list.

Cheers

M

-- 
Matthew Smith
Kadina Business Consultancy
South Australia
http://www.kbc.net.au

Received on Wednesday, 1 October 2003 06:41:39 UTC