HTML::Form Module and <button> element clicks

"Daniel Hedlund" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
<button> element is not supported correctly in HTML::Form module.  Button elements are not clickable using the method ->click().  They are not even parsed into an input object due to its type being set to "IgnoreInput" in the %type2class hash.

The default action for <button> should be equivalent to <input type="submit">, at least according to HTML 4.01 and XHTML 1.0 strict DTDs:
http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON
http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-strict.dtd_button

I could understand ignoring the button for other button types such as type="reset" or type="button", but not "submit" which is default.  Is there any particular reason why button elements are not supported?

I've attached a patch against the latest /lwp5/lib/HTML/Form.pm CVS version that will add support for clicking <button> elements.

Cheers,

Daniel Hedlund
Software Engineer
-----------------------
ePrize
One ePrize Drive
Pleasant Ridge, MI 48069
Ph: 248.543.6800
Fax: 248.543.3777
[email protected]
 
Interactive Promotion Results
www.eprize.com
Form.pm.patch (application/octet-stream, 861 B)
--- Form-original.pm	2005-12-07 09:32:27.000000000 -0500
+++ Form.pm	2007-05-08 13:26:16.000000000 -0400
@@ -18,5 +18,4 @@
  textarea => "TextInput",
 
- button   => "IgnoreInput",
  "reset"  => "IgnoreInput",
 
@@ -25,4 +24,5 @@
  option   => "ListInput",
 
+ button   => "SubmitInput",
  submit   => "SubmitInput",
  image    => "ImageInput",
@@ -118,5 +118,5 @@
     eval {
 	# optimization
-	$p->report_tags(qw(form input textarea select optgroup option keygen label));
+	$p->report_tags(qw(form input textarea select optgroup option keygen label button));
     };
 
@@ -184,4 +184,8 @@
 		    $f->push_input($type, $attr);
 		}
+        elsif ($tag eq "button") {
+            my $type = delete $attr->{type} || "submit";
+            $f->push_input($type, $attr);
+        }
 		elsif ($tag eq "textarea") {
 		    $attr->{textarea_value} = $attr->{value}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.