develooper Front page | perl.libwww | Postings from June 2000

HTML::Form patch, adds name attribute

Thread Next
From:
Edward Jason Riedy
Date:
June 7, 2000 12:42
Subject:
HTML::Form patch, adds name attribute
Message ID:
200006071942.MAA16742@lotus.CS.Berkeley.EDU
This would be handy to me.  Relying on a particular name is probably 
about as fragile as relying on the order of forms, but it feels nicer.

Jason

--- Form.pm.orig	Wed Jun  7 12:33:18 2000
+++ Form.pm	Wed Jun  7 12:36:54 2000
@@ -64,6 +64,7 @@
     $self->{method} = uc(shift  || "GET");
     $self->{action} = shift  || Carp::croak("No action defined");
     $self->{enctype} = shift || "application/x-www-form-urlencoded";
+    $self->{name} = shift || undef;
     $self->{inputs} = [@_];
     $self;
 }
@@ -94,12 +95,14 @@
     while (my $t = $p->get_tag) {
 	my($tag,$attr) = @$t;
 	if ($tag eq "form") {
+	    my $name = $attr->{'name'};
 	    my $action = $attr->{'action'};
 	    $action = "" unless defined $action;
 	    $action = URI->new_abs($action, $base_uri);
 	    $f = $class->new($attr->{'method'},
 			     $action,
-			     $attr->{'enctype'});
+			     $attr->{'enctype'},
+			     $name);
 	    push(@forms, $f);
 	    while (my $t = $p->get_tag) {
 		my($tag, $attr) = @$t;
@@ -172,14 +175,16 @@
 
 =item $form->enctype( [$new] )
 
+=item $form->name( [$new] )
+
 These method can be used to get/set the corresponding attribute of the
 form.
 
 =cut
 
 BEGIN {
-    # Set up some accesor
-    for (qw(method action enctype)) {
+    # Set up some accessor
+    for (qw(method action enctype name)) {
 	my $m = $_;
 	no strict 'refs';
 	*{$m} = sub {

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About