Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: (jeffa) Re: Generalising Forms from CGI.pm

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 CGI.pm
in thread Generalising Forms from CGI.pm

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"


Comment on Re: (jeffa) Re: Generalising Forms from CGI.pm
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-07-08 04:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls