Graham TerMarsch writes:
> [...]
> Note that I haven't -tried- the following code, but it'd look something like:
>
> package MyApp;
>
> use base 'CGI::Application';
> use CGI::Application::Plugin::ValidateRM;
> use Data::FormValidator::Constraints qw(:regexp_common);
>
> sub setup {
> my $self = shift;
> $self->start_mode( 'mypage' );
> $self->run_modes( [qw( mypage )] );
> }
>
> sub mypage {
> my $self = shift;
> if ($self->query->param('submit_button')) {
> return $self->processMypage(@_);
> }
> return $self->showMypage(@_);
> }
>
> sub showMypage {
> my ($self, $errs) = @_;
> my $html = <<EOHTML;
> <html>
> <body>
> <form name="silly" method="post" action="mypage">
> <input type="text" name="widget" value="" size=25>
> <input name="submit_button" type="submit" value="submit" />
> </form>
> </body>
> </html>
> EOHTML
> return ($html);
> }
>
> sub processMypage {
> my $self = shift;
> # validate, showing error if invalid
> my $res = $self->check_rm( 'mypage',
> { 'required' => [qw( widget )],
> 'defaults' => {
> 'widget' => 1,
> },
> 'constraint_methods' => {
> 'widget' => FV_num_int(),
> },
> 'msgs' => {
> 'any_errors' => 'dfv_errors',
> 'prefix' => 'err_',
> },
> } );
> unless ($res) {
> return $self->check_rm_error_page();
> }
> # data ok, show form again.
> return $self->showMypage();
> }
This suffers from the same problem that's been biting me, you've just
added another level of indirection.
mypage gets called and sees the submit_button
it calls processMypage, which check_rm's, see's the bad value and
calls check_rm_error_page, which points back to mypage
mypage gets called and sees the submit_button
etc....
I'll go and check on Mark's Aug. 9th proposal.
Thanks,
g.
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]