in reply to CGI::Application, have I made a big mistake.
The way I look at it, I have separate run_mode's for every "page" or step in the application. Then (following your example), when mode_001 is processed/submitted, it goes to mode_002 (instead of back to mode_001) and in mode_002's run_mode method, I use ValidateRM's check_rm method, which will take care of your error handling for you and you can tell it which run_mode to return to, if there was an error.
sub mode_001 { my ( $self, $errs ) = @_; # ... $template->param( $errs ) if $errs; $template->output; } sub mode_002 { my ( $self, $results, $err_page ); $self = shift; ( $results, $err_page ) = $self->check_rm( 'mode_001', '_mode001_profile' ); return $err_page if $err_page; # If you've gotten this far, all the data is ok per # your FormValidator object } sub _mode001_profile { return { 'required' => [ qw( email password1 password2 ) ], 'constraints' => { 'email' => sub { return Email::Valid->address( shift ) +; } }, 'msgs' => { 'any_errors' => 'some_errors', 'prefix' => 'err_', }, }; }
Hope that helps!
Peace,
Jason
Update: It will also prefill out the previous form with the user's data when/if it returns to a previous run_mode. So if they provided their first e-mail address, but not any other stuff, then it will represent the original form with the data that the user did specify along with those 'msgs' (i.e. err_password1, err_password2) that you can incorporate into your template to color things red or whatever.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: CGI::Application, have I made a big mistake.
by freddo411 (Chaplain) on Nov 25, 2003 at 18:22 UTC | |
by jdtoronto (Prior) on Nov 27, 2003 at 20:48 UTC | |
|
Re: Re: CGI::Application, have I made a big mistake.
by jdtoronto (Prior) on Nov 25, 2003 at 15:37 UTC |