=head1 DESCRIPTION
-This portion of the tutorial explores L<HTML::FormFu|HTML::FormFu> and
+This portion of the tutorial explores L<HTML::FormFu> and
how it can be used to manage forms, perform validation of form input,
as well as save and restore data to/from the database. This was written
using HTML::FormFu version 0.05001.
See
-L<Catalyst::Manual::Tutorial::09_AdvancedCRUD|Catalyst::Manual::Tutorial::09_AdvancedCRUD>
+L<Catalyst::Manual::Tutorial::09_AdvancedCRUD>
for additional form management options other than
-L<HTML::FormFu|HTML::FormFu>.
+L<HTML::FormFu>.
=head1 HTML::FormFu FORM CREATION
-This section looks at how L<HTML::FormFu|HTML::FormFu> can be used to
+This section looks at how L<HTML::FormFu> can be used to
add additional functionality to the manually created form from Chapter 4.
=head2 Inherit From Catalyst::Controller::HTML::FormFu
First, change your C<lib/MyApp/Controller/Books.pm> to inherit from
-L<Catalyst::Controller::HTML::FormFu|Catalyst::Controller::HTML::FormFu>
+L<Catalyst::Controller::HTML::FormFu>
by changing the C<extends> line from the default of:
BEGIN {extends 'Catalyst::Controller'; }
# Get the form that the :FormConfig attribute saved in the stash
my $form = $c->stash->{form};
-
+
# Check if the form has been submitted (vs. displaying the initial
# form) and if the data passed validation. "submitted_and_valid"
# is shorthand for "$form->submitted && !$form->has_errors"
# Add the authors to it
$select->options(\@authors);
}
-
+
# Set the template
- $c->stash->{template} = 'books/formfu_create.tt2';
+ $c->stash(template => 'books/formfu_create.tt2');
}
=head2 Create a Form Config File
Although C<HTML::FormFu> supports any configuration file handled by
-L<Config::Any|Config::Any>, most people tend to use YAML. First
+L<Config::Any>, most people tend to use YAML. First
create a directory to hold your form configuration files:
mkdir -p root/forms/books
display: block;
}
-These changes will display form elements vertically. Note that the
-existing definition of the C<.error> class is pulling the color scheme
-settings from the C<root/lib/config/col> file that was created by the
-TTSite helper. This allows control over the CSS color settings from a
-single location.
+These changes will display form elements vertically.
=head2 Create a Template Page To Display The Form
=head1 HTML::FormFu VALIDATION AND FILTERING
-Although the use of L<HTML::FormFu|HTML::FormFu> in the previous section
+Although the use of L<HTML::FormFu> in the previous section
did provide an automated mechanism to build the form, the real power of
this module stems from functionality that can automatically validate and
filter the user input. Validation uses constraints to be sure that
=item *
Constraints are added to provide validation of the user input. See
-L<HTML::FormFu::Constraint|HTML::FormFu::Constraint> for other
+L<HTML::FormFu::Constraint> for other
constraints that are available.
=item *
A variety of filters are run on every field to remove and escape
-unwanted input. See L<HTML::FormFu::Filter|HTML::FormFu::Filter>
+unwanted input. See L<HTML::FormFu::Filter>
for more filter options.
=back
}
# Set the template
- $c->stash->{template} = 'books/formfu_create.tt2';
+ $c->stash(template => 'books/formfu_create.tt2');
}
Most of this code should look familiar to what we used in the
real reason you worked through this Tutorial in the first place.
-=head2 Config::General Config for this tutorial
+=head2 Config::General Config for this tutorial
If you are having difficulty with YAML config above, please save the
below into the file C<formfu_create.conf> and delete the
C<formfu_create.yml> file. The below is in
-L<Config::General|Config::General> format which follows the syntax of
+L<Config::General> format which follows the syntax of
Apache config files.
constraints Required
type Submit
</elements>
indicator submit
-
+
=head1 AUTHOR
Kennedy Clark, C<hkclark@gmail.com>
-Please report any errors, issues or suggestions to the author. The
-most recent version of the Catalyst Tutorial can be found at
+Feel free to contact the author for any errors or suggestions, but the
+best way to report issues is via the CPAN RT Bug system at
+<https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Manual>.
+
+The most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/>.
-Copyright 2006-2008, Kennedy Clark, under Creative Commons License
-(L<http://creativecommons.org/licenses/by-sa/3.0/us/>).
+Copyright 2006-2010, Kennedy Clark, under the
+Creative Commons Attribution Share-Alike License Version 3.0
+(L<http://creativecommons.org/licenses/by-sa/3.0/us/>).