Anders Nor Berle > Catalyst-Controller-MetaForm > Catalyst::Controller::MetaForm

Download:
Catalyst-Controller-MetaForm-0.01_03.tar.gz

Dependencies

Annotate this POD

Module Version: 0.01_03   Source  

NAME ^

Catalyst::Controller::MetaForm - MetaForm sugar for Catalyst

SYNOPSIS ^

  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;

DESCRIPTION ^

See Class::MetaForm for an actual description.

MORE SUGARING? ^

Add the following snippet to your MyApp.pm for quick access to your stashed form.

  sub form { shift->stash->{ form } }

SEE ALSO ^

Catalyst
Class::MetaForm

BUGS ^

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.

AUTHOR ^

Anders Nor Berle <berle@cpan.org>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: