Catalyst::Controller::MetaForm - MetaForm sugar for Catalyst
package MyApp::Form::Login; use Moose; use Class::MetaForm; has username => ( is => 'ro', isa => 'Str', required => 1, ); has password => ( is => 'ro', isa => 'Str', required => 1, ); package MyApp::Controller::Auth; use base qw/Catalyst::Controller::MetaForm/; use strict; use warnings; # This will require the form MyApp::Form::Login to be successfully # validated before the code gets to execute. sub login : Local AssertForm('Login') Args(0) { my ($self,$c) = @_; # We will always have $c->stash->{ form } here. } # In this case, the form MyApp::Form::Something doesn't have to be # valid in order for the action to execute. sub somethingelse : Local Form('Login') Args(0) { my ($self,$c) = @_; # $c->stash->{ form } will be undefined if it wasn't successfully # validated. The error can be found in $c->stash->{ form_error } } 1;
See Class::MetaForm for an actual description.
Add the following snippet to your MyApp.pm for quick access to your stashed form.
sub form { shift->stash->{ form } }
Most software has bugs. This module probably isn't an exception. If you find a bug please either email me, or add the bug to cpan-RT.
Anders Nor Berle <berle@cpan.org>
Copyright 2009 by Modula AS
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Controller::MetaForm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Controller::MetaForm
CPAN shell
perl -MCPAN -e shell install Catalyst::Controller::MetaForm
For more information on module installation, please visit the detailed CPAN module installation guide.