As a quickie review, each page ($state) has it's own sub to display its goodies ($sub), depending on if it's the active page (show an entire screen) or not (print out hidden fields) and it gave me the idea that I eventually implemented. Each sub that shows a screen checks the parameters of its predecessor (or calls a sub that checks the parameters), and if some of them fail validity checking, calls the predecessor's sub with an error code... so, one of my original subs looked something likewhile (($state, $sub) = each %States) { $sub->( $page eq $state ); }
and after some renooberation, I came up withsub show_secondstep { my $active = shift; if ($active) { -- print out form -- } else { -- print out hidden fields -- } }
So the new second step will verify all of the 1st step's fields, and call show_firststep with a parameter higher than 1 to indicate that something wasn't filled out correctly. As the one of the above posts says "does anyone else see the beauty and power of this? :) " This seems like a fast and efficient way to enforce data veracity, and I look forward to your comments.sub show_secondstep { my $active = shift; if ($active ==0) { -- print hidden -- } if ($active >=1) { if ($active == 2) { print "Please fill out all fields."} if (-- firststep fields OK --) { -- print this page -- } else { return show_firststep (2) } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Cgi recipe contemplations
by merlyn (Sage) on Nov 14, 2000 at 19:08 UTC | |
|
RE: Cgi recipe contemplations
by extremely (Priest) on Nov 15, 2000 at 10:12 UTC |