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

[cgiapp] ValidateRM and Template problem


Having got C:A working with Template.pm and CGI::FormBuilder, my next
task is to get C:A:ValidateRM working. Integrating a working example
(http://mark.stosberg.com/Tech/perl/form-validation/) into my
application, I find it works OK if I use HTML::Template in
form_display(), but not if I use Template. Submitting a form which
should fail validation still loads the 'success' page:

sub form_display {
  my $self = shift;
  my $errs = shift;

  my $vars = {
    errs => $errs,
  };

######### Template.pm method (doesn't work - loads 'success' mode_2)
# return $self->tt_process($vars); # auto-generates template
#########

######### HTML::Template method (works OK)
  my $t =
$self->load_tmpl('/127.0.0.1/htdocs/templates/MyApp/form_display_ht.tmpl',
die_on_bad_params=>0);

  $t->param($errs) if ref $errs;

  return $t->output;
#########
}

sub form_process {
  my $self = shift;

  my ($results, $errors) = $self->check_rm('form_display',
'_form_profile');

  return $errors if $errors;

  print $fh "WE SHOULD NOT BE HERE USING Template.pm IN form_display()
IF FORM VALIDATION FAILED!!\n";

  #..  do something with DFV $results object now

  $self->mode_2(); # go to mode_2 if success
}

Method flow using HTML::Template is:
cgiapp_init -> setup -> cgiapp_prerun -> form_process -> form_display ->
cgiapp_postrun -> teardown

Method flow using Template.pm:
cgiapp_init -> setup -> cgiapp_prerun -> form_process -> form_display ->
tt_post_process -> mode_2 ->tt_post_process -> cgiapp_postrun ->teardown

mode_2 should only be called for a successful form validation. Hope I've
given enough details. Any ideas what is wrong here?
-- 
Richard Jones
Leeds, UK
mailto:suppressed

---------------------------------------------------------------------
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.