Below is a full FormFu skeleton.

sub input_formfu : Local {
my ( $self, $c ) = @_;

# Create form object
my $form = $self->form;

# Load form configuration from a yaml file

# Pass catalyst request object to form query method 
# Used only in POST phase.
$form->query( $c->req );

# Process the form - done in both GET/POST phases.

# Put the form in the stash for template rendering 
# Used in GET.
$c->stash->{form} = $form;

=head1 Form GET

Show the form.  
View falls through to default template if none specified. 
Default template = data/ which in general is $controller_path/$
.tt is the extension becatse that has been chose as the default view type.


if ( !$form->submitted ) {

elsif ( $form->submitted_and_valid ) {
    $c->log->debug('Form Submitted and Valid');

    # Do something with the form data
            'Form has been succesfully submitted.  I better do something with it.'

=head1 Form Errors

One of the reasons to use a form helper module such as FormFu is that
it will automatically show errors messages based on form constraints
setup in the configuration.  The constraints can be as simple as requiring
a non-empty input field or being more restrictive by specifying the data type
such as Integer, Word, Email etc.


elsif ( $form->has_errors ) {
    $c->stash->{error_msg} = "Forms has errors";
    $c->log->debug('Form has Errors');
else {
    $c->log->debug('How the heck did I GET here');


NOTE: This action (subroutine in Catalyst context) comes from a controller class called

My tags:
Popular tags:
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker