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.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.
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 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.
In reply to Re: Retrieving "msgs" values from Data::FormValidator
by jdtoronto
in thread Retrieving "msgs" values from Data::FormValidator
by Hagbone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |