Subject: | [PATCH] implement a "form_id" method analogous to form_name() |
In xhtml strict, the "name" attribute is not allowed on <form> tags.
Instead, the "id" attribute should be used.
Below is a simple implementation of a new form_id() method. It is just
like form_name() except for the attribute it checks.
Chris
sub form_id {
my ($self, $formid) = @_;
my $temp;
my @matches = grep {defined($temp = $_->attr('id'))
and ($temp eq $formid) } $self->forms;
if ( @matches ) {
$self->warn( "There are ", scalar @matches,
" forms with id $formid. The first one was used." )
if @matches > 1;
return $self->{form} = $matches[0];
}
else {
$self->warn( qq{ There is no form with id "$formid"} );
return undef;
}
}