http://qs321.pair.com?node_id=258195

wil has asked for the wisdom of the Perl Monks concerning the following question:

I'm having some /more than likely logical/ problems with building and returning forms using CGI::Application::ValidateRM. This is a fairly new module to access Data::FormValidator using CGI::Application's interface.

The module looks good, and it looks like it will hoenstly work, but I've just got problems passing paramters around through CGI. So don't worry about the choice of module, but concentrate on how I'm /not/ passing arguments between subs.

_form_register_profile should pick up $q->param{email} from the form, but doesn't for some reason. Well the reason being that I haven't passed it, I'm sure -- but I need help on how to do this. If anyone understands my cryptic question-answering strategy and can help me out it'd be most appreciated.

###################################################################### +################# sub register_form { # -------------------------------------------------------------------- +------ # Output registration form. # my $self = shift; my $errs = shift; my $q = $self->query(); $self->set_session($q->cookie('SID')); my $lang_bit = $self->{session}{lang} || $q->param('lang'); my $tmpl_path = "dynamic/" . $lang_bit . "_" . "register.shtml"; my $tmpl = $self->load_tmpl($tmpl_path, die_on_bad_params => 0); $tmpl->param($errs) if $errs; return $tmpl->output; } ###################################################################### +################# sub register_process { # -------------------------------------------------------------------- +------ # Process registration form using CGI::Application::ValidateRM to c +heck # for blank required fields.. # my $self = shift; my $q = $self->query(); my ($results, $err_page) = $self->check_rm('register_form','_form +_register_profile'); return $err_page if $err_page; #.. do something with DFV $results object now my $lang_bit = $self->{session}{lang} || $q->param('lang'); my $tmpl_path = "dynamic/" . $lang_bit . "_" . "register_success.s +html"; my $tmpl = $self->load_tmpl($tmpl_path, die_on_bad_params => 0); return $tmpl->output; } ###################################################################### +################# sub _form_register_profile { # -------------------------------------------------------------------- +------ # Internal sub called from register_process to determine required # form variables for registration form. # return { required => 'email', }; } ###################################################################### +#################

Error Message:

[Wed May 14 19:10:33 2003] [error] Error executing run mode 'register_ +process'. Eval of code '$self->register_process' resulted in error: +Can't use an undefined value as a HASH reference at /usr/local/lib/pe +rl5/site_perl/5.6.1/Data/FormValidator/Results.pm line 570.
- wil

Replies are listed 'Best First'.
Re: CGI Application and Forms
by markjugg (Curate) on May 15, 2003 at 16:06 UTC
    I helped wil with this off-site. The short term answer in was to add msgs=>{} to the profile. The longer term solution is for DFV to fail more gracefully in this case, or better, Just Work.

    Mark