#
# My intention for this package is to construct a set of modules that
# will allow me to easily display a pre-"configured" CGI::FormBuilder
# object.
#
# This outputs the surrounding html as well as some of the data
# set in &new below (see comments). However, other vital parts,
# such as generated javascript and form elements, are obviously broken.
#
# <!-- Generated by CGI::FormBuilder v3.04 available from www.formbuilder.org -->
# <form action="test.pl" id="Signup" method="get" name="Signup">
# <div>
# <input id="_submitted_Signup" name="_submitted_Signup" type="hidden" value="1" />
# <table>
# MSI::Form::Signup=HASH(0x830c6f0)
# </table>
#
# <tr id="Signup_firstname_row" valign="top">
# <td>MSI::Form::Signup=HASH(0x830c6f0) id Signup_firstname_label class </td>
#
# ...
#
#
package MSI::Form::Signup;
use strict;
use warnings;
use CGI::Pretty qw/:standard/;
use CGI::FormBuilder;
our @ISA = qw/CGI::FormBuilder/;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my @fields = qw(firstname surname);
#
# The below works perfectly well when excluded from my package.
# Clearly I need more perl practice..
#
my $self = $class -> SUPER::new (
name => 'Signup',
fields => \@fields,
text => h2('Join the community!'), # this is outputted
header => 0,
validate => {
firstname => 'NAME',
surname => 'NAME'
}
);
#
# This string is outputted as expected (or, rather, as I was hoping for).
#
$self -> fields( name => 'firstname', label => 'Please enter your first name');
#
# I guess this is re-blessing, and a bad idea?
#
return bless $self, $class;
}
1;