Hagbone has asked for the wisdom of the Perl Monks concerning the following question:
Case in point - I've set up a test form with 8 fields. The first four fields are required, and the last four fields are optional. When submitting the form, I'm intentionally leaving two of the four required fields blank - I'm trying to get FormValidator to spit back some sort of error message(s).
I'm able to have the script report the missing (and required) fields, but I can't seem to get any error message reports back from the module using the $results->(msgs) call. Here's the script code:
And here's the HTML output:#!/usr/bin/perl use CGI qw(:standard); use strict; use Data::FormValidator; my $q = new CGI; my $profile = { required => [qw(one two three four)], optional => [qw(five six seven eight)], msgs =>{}, }; print "Content-type:text/html\n\n"; my %fdat = $q->Vars; my $results = Data::FormValidator->check(\%fdat, $profile); if ($results->has_missing) { foreach ($results->missing() ) { print "missing field name: $_ <br>"; } foreach ($results->msgs() ) { print "msgs output: $_ <br>"; } } exit;
missing field name: three
missing field name: two
msgs output: HASH(0x81ff9dc)
I've got this feeling that I'm missing something very fundamental here, but for the life of me, I can't figure it out. I've searched high and low for references to results->(msgs), and was unable to understand what little I found .... any help is appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Retrieving "msgs" values from Data::FormValidator
by jdtoronto (Prior) on Dec 20, 2003 at 16:08 UTC | |
by Hagbone (Monk) on Dec 20, 2003 at 17:42 UTC | |
|
Re: Retrieving "msgs" values from Data::FormValidator
by cees (Curate) on Dec 20, 2003 at 17:42 UTC | |
|
Re: Retrieving "msgs" values from Data::FormValidator
by Hagbone (Monk) on Dec 20, 2003 at 20:08 UTC | |
by cees (Curate) on Dec 21, 2003 at 00:29 UTC | |
by Hagbone (Monk) on Dec 21, 2003 at 20:14 UTC |