X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2F09_AdvancedCRUD%2F09_FormFu.pod;h=a566e925fce68a6a5104bbea7e4829cf916e154d;hp=52225af923ba9e6993e46b4c9d13b990a448c7e8;hb=2217b252905d370f4f7840cf78996d43c79e5d4f;hpb=96a8735673ba59a0cdc20672020dffab4d6209de diff --git a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod index 52225af..a566e92 100644 --- a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod +++ b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod @@ -56,27 +56,27 @@ L =head1 DESCRIPTION -This portion of the tutorial explores L and +This portion of the tutorial explores L 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 +L for additional form management options other than -L. +L. =head1 HTML::FormFu FORM CREATION -This section looks at how L can be used to +This section looks at how L 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 to inherit from -L +L by changing the C line from the default of: BEGIN {extends 'Catalyst::Controller'; } @@ -85,6 +85,11 @@ to use the FormFu base controller class: BEGIN {extends 'Catalyst::Controller::HTML::FormFu'; } +Don't forget to add: + + requires 'Catalyst::Controller::HTML::FormFu'; + +to your C. =head2 Add Action to Display and Save the Form @@ -131,14 +136,14 @@ following method: } # 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 supports any configuration file handled by -L, most people tend to use YAML. First +L, most people tend to use YAML. First create a directory to hold your form configuration files: mkdir -p root/forms/books @@ -219,7 +224,8 @@ Open C in your editor and enter the following: [%# Render the HTML::FormFu Form %] [% form %] -

Return to book list

+

Return to book list

=head2 Add Links for Create and Update via C @@ -239,19 +245,18 @@ use to easily launch our HTML::FormFu-based form. =head2 Test The HTML::FormFu Create Form -Press C to kill the previous server instance (if it's still -running) and restart it: +Make sure the server is running with the "-r" restart option: - $ script/myapp_server.pl + $ script/myapp_server.pl -r Login as C (password: mypass). Once at the Book List page, click the new HTML::FormFu "Create" link at the bottom to display the form. Fill in the following values: -Title: Internetworking with TCP/IP Vol. II -Rating: 4 -Author: Comer - + Title: Internetworking with TCP/IP Vol. II + Rating: 4 + Author: Comer + Click the Submit button, and you will be returned to the Book List page with a "Book created" status message displayed. @@ -273,7 +278,7 @@ performing any validation. =head1 HTML::FormFu VALIDATION AND FILTERING -Although the use of L in the previous section +Although the use of L 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 @@ -388,13 +393,13 @@ C and C options in C. =item * Constraints are added to provide validation of the user input. See -L for other +L for other constraints that are available. =item * A variety of filters are run on every field to remove and escape -unwanted input. See L +unwanted input. See L for more filter options. =back @@ -402,11 +407,6 @@ for more filter options. =head2 Try Out the Updated Form -Press C to kill the previous server instance (if it's still -running) and restart it: - - $ script/myapp_server.pl - Make sure you are still logged in as C and try adding a book with various errors: title less than 5 characters, non-numeric rating, a rating of 0 or 6, etc. Also try selecting one, two, and zero authors. @@ -473,7 +473,7 @@ bottom: } # 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 @@ -539,11 +539,6 @@ existing C link. =head2 Try Out the Edit/Update Feature -Press C to kill the previous server instance (if it's still -running) and restart it: - - $ script/myapp_server.pl - Make sure you are still logged in as C and go to the L URL in your browser. Click the "Edit" link next to "Internetworking with TCP/IP Vol. II", change the @@ -585,12 +580,12 @@ Or you can proceed to write your own application, which is probably 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 and delete the C file. The below is in -L format which follows the syntax of +L format which follows the syntax of Apache config files. constraints Required @@ -643,9 +638,13 @@ Apache config files. Kennedy Clark, C -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 +. + +The most recent version of the Catalyst Tutorial can be found at L. -Copyright 2006-2008, Kennedy Clark, under Creative Commons License -(L). +Copyright 2006-2010, Kennedy Clark, under the +Creative Commons Attribution Share-Alike License Version 3.0 +(L).