[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Found the problem with ValidateRM & Template


> -----Original Message-----
> From: RA Jones [mailto:suppressed 
> Sent: Wednesday, April 13, 2005 10:08 PM
> To: suppressed
> Subject: Re: [cgiapp] Found the problem with ValidateRM & Template
> 
> 
> Thanks, if it helps, these are the two subs responsible. 
> form_display()
> displays the page correctly on first parsing, providing I supply an
> empty hashref to $errors, as tt_process() requires a hashref in its
> arguments. Then when I submit the form with empty (but 
> required) fields,
> form_process() is invoked, which incorrectly returns the 
> 'success' page
> because $errors is empty.
> 
> sub form_display {
>   my $self = shift;
>   my $errors = shift || {}; # print $fh Dumper($errors); # hashref of
> errors
> 
>   return $self->tt_process($errors); # produces scalarref 
> which doesn't
> work in ValidateRM::check_rm()
> }
> 
> sub form_process { # called by hidden 'rm' field in form_display()
> template
>   my $self = shift;
> 
>   my ($results, $errors) = $self->check_rm('form_display',
> '_form_profile'); # field defs. in _form_profile()
> 
>   if ($errors) {
>     return $errors;
>   }
>   else {
>     #..  do something with DFV $results object now
>     $self->menu(); # go to menu if success
>   }
> }
> 
> The output of form_display() ie $self->tt_process($errors), is a
> scalarref. The equivalent output from form_display() if using H::T
> instead is a scalar. Presumably for C:A:ValidateRM to work correctly
> with TT the value of $self->tt_process($errors) needs to be a scalar
> also, [...]

Richard, as I've alredy said this is not a problem, since
CAP::ValidateRM::check_rm() takes indifferently either a text and a text
reference, as returned by the "return" run mode: no problems at all
(this is true also for CGI::Application::ValidateRM).

Last second addition: I've just discovered (by reading the changelog)
that this is true only for CGI::Application::ValidateRM ver. >= 1.10;
previous versions (1.07, which dates back to Oct 2003, and older
versions) seem to not support "returning scalar refs from the run mode
being validated".
So, if you are using a such old version, switch to the latest one, or
rather to CAP::ValidateRM (read the following).

As a side note, I would suggest to use
CGI::Application::Plugin::ValidateRM and not
CGI::Application::ValidateRM as you seem to do: there should be no
(substantial) difference, but the former is a more recent module and
it's the recommended one (anyway use it only *after* your experiments
with CAP::TT alone! ;-)

Ciao,
Emanuele.


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.