Skip Menu |

This queue is for tickets about the HTML-SuperForm CPAN distribution.

Report information
The Basics
Id: 48773
Status: resolved
Worked: 2 min
Priority: 0/
Queue: HTML-SuperForm

People
Owner: jallwine86 [...] yahoo.com
Requestors: mschout [...] gkg.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Add support for reset tag
Date: Mon, 17 Aug 2009 11:01:13 -0500
To: bug-HTML-SuperForm [...] rt.cpan.org
From: Michael Schout <mschout [...] gkg.net>
The attached patch adds support for the reset tag.
From c8552175654addf08be4192cb08ad8ca15040ba4 Mon Sep 17 00:00:00 2001 From: Michael Schout <mschout@gkg.net> Date: Mon, 17 Aug 2009 10:58:35 -0500 Subject: [PATCH] add support for reset tag --- lib/HTML/SuperForm.pm | 2 +- lib/HTML/SuperForm/Field/Reset.pm | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletions(-) create mode 100644 lib/HTML/SuperForm/Field/Reset.pm diff --git a/lib/HTML/SuperForm.pm b/lib/HTML/SuperForm.pm index 84652fa..b4d79e7 100644 --- a/lib/HTML/SuperForm.pm +++ b/lib/HTML/SuperForm.pm @@ -6,7 +6,7 @@ use Carp; our $VERSION = 1.05; -my %fields = map { $_ => 1 } qw(textarea text checkbox select radio checkbox_group radio_group password hidden submit); +my %fields = map { $_ => 1 } qw(textarea text checkbox select radio checkbox_group radio_group password hidden submit reset); my %mutators = map { $_ => 1 } qw(well_formed sticky fallback values_as_labels); my %accessors = map { $_ => 1 } qw(field_object params); diff --git a/lib/HTML/SuperForm/Field/Reset.pm b/lib/HTML/SuperForm/Field/Reset.pm new file mode 100644 index 0000000..e84e13e --- /dev/null +++ b/lib/HTML/SuperForm/Field/Reset.pm @@ -0,0 +1,55 @@ +package HTML::SuperForm::Field::Reset; + +use base 'HTML::SuperForm::Field'; +use strict; + +sub init { + my $self = shift; + my $config = shift; + + unless(exists($config->{label})) { + if(exists($config->{default})) { + $config->{label} = $config->{default}; + } else { + $config->{label} = "Reset"; + } + } +} + +sub to_html { + my $self = shift; + my $tag = '<input type="reset"'; + $tag .= $self->attribute_str(); + $tag .= ' value="'; + $tag .= $self->label(); + $tag .= '"'; + $tag .= "/" if $self->well_formed; + $tag .= '>'; + + return $tag; +} + +1; + +__END__ + +=head1 NAME + +HTML::SuperForm::Field::Reset - Reset field used by HTML::SuperForm + +=head1 SYNOPSIS + + my $reset = HTML::SuperForm::Field::Reset name => 'my_reset', + default => 'Reset' ); + + print $reset; + +=head1 SEE ALSO + + HTML::SuperForm::Field + +=head1 AUTHOR + +John Allwine E<lt>jallwine86@yahoo.comE<gt> + +=cut -- 1.6.0.4
Applied the patch in 1.09