Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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"

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

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 drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2015-12-01 23:37 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (29 votes), past polls