Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I haven't seen anyone point you in the direction of CGI::Application::ValidateRM yet - that's what I've been using recently and it works great!

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.


In reply to Re: CGI::Application, have I made a big mistake. by Purdy
in thread CGI::Application, have I made a big mistake. by jdtoronto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found