Catalyst::Controller::HTML::FormFu

Catalyst integration for HTML::FormFu
Download

Catalyst::Controller::HTML::FormFu Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Publisher Name:
  • Carl Franks
  • Publisher web site:
  • http://search.cpan.org/~cfranks/

Catalyst::Controller::HTML::FormFu Tags


Catalyst::Controller::HTML::FormFu Description

Catalyst integration for HTML::FormFu Catalyst::Controller::HTML::FormFu is a Perl module that provides Catalyst integration for HTML::FormFu.SYNOPSIS package MyApp::Controller::My::Controller; use base 'Catalyst::Controller::HTML::FormFu'; sub index : Local { my ( $self, $c ) = @_; # doesn't use an Attribute to make a form # can get an empty form from $self->form() my $form = $self->form(); } sub foo : Local : Form { my ( $self, $c ) = @_; # using the Form attribute is equivalent to: # # my $form = $self->form; # # $form->process; # # $c->stash->{form} = $form; } sub bar : Local : FormConfig { my ( $self, $c ) = @_; # using the FormConfig attribute is equivalent to: # # my $form = $self->form; # # $form->load_config_filestem('root/forms/my/controller/bar'); # # $form->process; # # $c->stash->{form} = $form; # # so you only need to do the following... my $form = $c->stash->{form}; if ( $form->submitted_and_valid ) { do_something(); } } sub baz : Local : FormConfig('my_config') { my ( $self, $c ) = @_; # using the FormConfig attribute with an argument is equivalent to: # # my $form = $self->form; # # $form->load_config_filestem('root/forms/my_config'); # # $form->process; # # $c->stash->{form} = $form; # # so you only need to do the following... my $form = $c->stash->{form}; if ( $form->submitted_and_valid ) { do_something(); } } sub quux : Local : FormMethod('load_form') { my ( $self, $c ) = @_; # using the FormMethod attribute with an argument is equivalent to: # # my $form = $self->form; # # $form->populate( $c->load_form ); # # $form->process; # # $c->stash->{form} = $form; # # so you only need to do the following... my $form = $c->stash->{form}; if ( $form->submitted_and_valid ) { do_something(); } } sub load_form { my ( $self, $c ) = @_; # Automatically called by the above FormMethod('load_form') action. # Called as a method on the controller object, with the context # object as an argument. # Must return a hash-ref suitable to be fed to $form->populate() }You can also use specially-named actions that will only be called under certain circumstances. sub edit : Chained('group') : PathPart : Args(0) : FormConfig { } sub edit_FORM_VALID { my ( $self, $c ) = @_; my $form = $c->stash->{form}; my $group = $c->stash->{group}; $form->model->update( $group ); $c->response->redirect( $c->uri_for( '/group', $group->id ) ); } sub edit_FORM_NOT_SUBMITTED { my ( $self, $c ) = @_; my $form = $c->stash->{form}; my $group = $c->stash->{group}; $form->model->default_values( $group ); } Requirements: · Perl


Catalyst::Controller::HTML::FormFu Related Software