in reply to Retrieving "msgs" values from Data::FormValidator

Here is a D::FV that works.
sub qs_process { my $self = shift; my $dbh = $self->param('mydbh'); my ($results, $err_page) = $self->check_rm('qs_display', { required => [qw/upfirstname uplastname upemail upusername uppa +ssword confirm_password/], optional => [qw/upzip upcountry/], filters => ['trim'], constraints => { uppassword => { #Make sure passwords are the same name => 'user_passwords', constraint => \&check_password, params => [qw(uppassword confirm_password)], }, upusername => { #Is username unique? name => 'user_username', constraint => sub { !$self->check_username(lc $_[0]); +} }, upemail => 'email', upzip => 'zip_or_postcode', }, msgs => { any_errors => 'err__', prefix => 'err_', constraints => { 'user_passwords' => "Your passwords don't match", 'user_username' => "Username not unique", }, }, } ); return $err_page if $err_page; # #Stuff here to handle case of validation being succesfull.
Don't forget that your template must have a set of TMPL_VAR fields that match the error messages. This code is not functional as it has a couple of external validation functions you can't see.

Here is a fragment of the template that is used for this form, note the 'err_' series of TMPL_VAR's in the third column.

<form method="post" action="/app/app02.cgi"> <table border="0" cellpadding="0" cellspacing="2" width="490"> <tr> <td class="lbl" colspan="3"><font size="-1">Using this + form you can sign up for preview privileges on our system. You will +be able to see everything a full member would see, the only thing you + cannot do is actually make appointments.</font></td> </tr> <tr> <td class="lbl" width="160">First Name</td> <td class="value" width="230"><input type="text" name="upf +irstname" size="20"></td> <td class="err"><tmpl_var err_upfirstname></td> </tr> <tr> <td class="lbl" width="160">Last&nbsp;Name</td> <td class="value" width="230"><input type="text" name="upl +astname" size="20"></td> <td class="err"><tmpl_var err_uplastname></td> </tr>

If you want to see it at work it is on a development server at: http://posiedon.mine.nu/app/app02.cgi?rm=mode_001

jdtoronto PS I am on my out for about 8 hours, but msg me if you want some help and I can help later.

Replies are listed 'Best First'.
Re: Re: Retrieving "msgs" values from Data::FormValidator
by Hagbone (Monk) on Dec 20, 2003 at 17:42 UTC
    As I mentioned, I'm severely challenged in the ways of modular thinking ... I just wish I understood how the code you offered is applied to the example I listed.

    Also - many of the forms I'd like to Validate with D::FV are static HTML pages ... and I'm assuming that D::FV can be used in these situations?

    I feel like I'm close to being able to use the module to check form input ... I can retrieve the missing fields, etc., but can't seem to get past retrieving a hash reference similar to:     HASH(0x81ff9dc)     for the     results->msgs()     info/data instead of real stuff. It's feeling like there's something fundamental that I'm just not recognizing .....

    Thanks for your suggestion, jdtoronto, ... maybe one of these months I'll start to understand the concepts more clearly.