CGI-Application-Plugin-ValidateRM
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/ValidateRM.pm view on Meta::CPAN
In a CGI::Application module:
# This is the run mode that will be validated. Notice that it accepts
# some errors to be passed in, and on to the template system.
sub form_display {
my $self = shift;
my $errs = shift;
my $t = $self->load_tmpl('page.html');
$t->param($errs) if $errs;
return $t->output;
}
sub form_process {
my $self = shift;
use CGI::Application::Plugin::ValidateRM (qw/check_rm/);
my ($results, $err_page) = $self->check_rm('form_display','_form_profile');
return $err_page if $err_page;
#.. do something with DFV $results object now
my $t = $self->load_tmpl('success.html');
return $t->output;
}
sub _form_profile {
return {
required => 'email',
msgs => {
any_errors => 'some_errors',
prefix => 'err_',
},
};
}
In page.html:
<!-- tmpl_if some_errors -->
<h3>Some fields below are missing or invalid</h3>
<!-- /tmpl_if -->
<form>
<input type="text" name="email"> <!-- tmpl_var err_email -->
</form>
=head1 SEE ALSO
L<CGI::Application>, L<Data::FormValidator>, L<HTML::FillInForm>, perl(1)
=head1 AUTHOR
Mark Stosberg <mark@summersault.com>
=head1 MAILING LIST
If you have any questions, comments, bug reports or feature suggestions,
post them to the support mailing list! This the Data::FormValidator list.
To join the mailing list, visit L<http://lists.sourceforge.net/lists/listinfo/cascade-dataform>
=head1 LICENSE
Copyright (C) 2003-2005 Mark Stosberg <mark@summersault.com>
This module is free software; you can redistribute it and/or modify it
under the terms of either:
a) the GNU General Public License as published by the Free Software
Foundation; either version 1, or (at your option) any later version,
or
b) the "Artistic License"
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
the GNU General Public License or the Artistic License for more details.
For a copy of the GNU General Public License along with this program; if not,
write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
=cut
( run in 0.709 second using v1.01-cache-2.11-cpan-e93a5daba3e )