The enclosed code shows a Base class with a respond() subroutine that is useful for Data::FormValidator users. It also shows a subclass setting up the proper things in respond_enter so that respond() can "dispatch" appropriately.
sub respond { my $self = shift; warn Dumper $self; return $self unless $self =~ /Validate$/; warn 'checking results'; my $results = Data::FormValidator->check( $self->CGI, $self->dfv_pro +file ); warn Dumper $results; my $response_page; if ( $results->has_missing() || $results->has_invalid() ) { # There was something wrong w/ the data... $self->reflect->addSlots( results => $results ); $response_page = $self->redo_page } else { $response_page = $self->confirm_page } Class::Autouse->autouse($response_page); return $response_page; } ### and now the class that we subclass on the above... package Gimble::Page::Login::Validate; use base qw(Gimble::Page::Base); use Class::Autouse; use Data::Dumper; sub respond_enter { my $self = shift; $self->reflect->addSlots( redo_page => 'Gimble::Page::Login::Redo', confirm_page => 'Gimble::Page::Login::Confirm', dfv_profile => { msgs => { format => '%s' }, required => [ qw(login_name password) ], } ) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A CGI::Prototype respond() subroutine for Data::FormValidator users
by merlyn (Sage) on Feb 04, 2005 at 21:57 UTC | |
|
Re: A CGI::Prototype respond() subroutine for Data::FormValidator users
by cbrandtbuffalo (Deacon) on Feb 07, 2005 at 17:11 UTC | |
by metaperl (Curate) on Feb 07, 2005 at 18:39 UTC | |
by cbrandtbuffalo (Deacon) on Feb 07, 2005 at 21:01 UTC | |
|
Re: A CGI::Prototype respond() subroutine for Data::FormValidator users
by metaperl (Curate) on Feb 04, 2005 at 19:13 UTC | |
by merlyn (Sage) on Feb 04, 2005 at 22:00 UTC |