Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: (jeffa) Re: Generalising Forms from

by clscott (Friar)
on Feb 19, 2003 at 22:41 UTC ( #236860=note: print w/replies, xml ) Need Help??

in reply to (jeffa) Re: Generalising Forms from
in thread Generalising Forms from

I can't believe no one has mentioned CGI::Formbuilder yet:

I believe that Nathan Wiger has scratched this itch particularly well, making it very straight forward to do complicated things with CGI forms very simply.

For posperity here is the SYNOPSYS from the documentation

use CGI::FormBuilder; # Let's assume we did a DBI query to get existing values my $dbval = $sth->fetchrow_hashref; my $form = CGI::FormBuilder->new( method => 'POST', fields => [qw/name email phone gender/], values => $dbval, validate => { email => 'EMAIL', phone => 'PHONE' } +, required => 'ALL', font => 'arial,helvetica', ); # Change gender field to have options $form->field(name => 'gender', options => [qw/Male Female/]); if ($form->submitted && $form->validate) { my $fields = $form->field; # get form fields as hashref # Do something to update your data (you would write this) do_data_update($fields->{name}, $fields->{email}, $fields->{phone}, $fields->{gender}); # Show confirmation screen print $form->confirm(header => 1); # Email the person a brief confirmation $form->mailconfirm(to => $fields->{email}); } else { # Print out the form print $form->render(header => 1); }
Clayton aka "Tex"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://236860]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2016-10-28 17:14 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (386 votes). Check out past polls.