X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2F09_AdvancedCRUD%2F09_FormFu.pod;h=3ef5fd49624b331e11180643a9e977b64bb9fabb;hb=e8200f38d465b85ad84eb11718db1e61230ce73b;hp=68f40917b2604760a14cb6bcada3d3fdc3c36192;hpb=5988477160c698d0e5efd1cf1911845d40a327cf;p=catagits%2FCatalyst-Manual.git
diff --git a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod
index 68f4091..3ef5fd4 100644
--- a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod
+++ b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod
@@ -56,77 +56,64 @@ L
=head1 DESCRIPTION
-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.03007.
+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.
-See
-L
-for additional form management options other than
-L.
+See L for additional form
+management options other than L.
-
-=head1 Install HTML::FormFu
-
-If you are following along in Debian 5, it turns out that some of the
-modules we need are not yet available as Debian packages at the time
-this was written. To install it with a combination of Debian packages
-and traditional CPAN modules, first use C to install most of
-the modules:
-
-we need to install the
-L package:
-
- sudo aptitude -y install libhtml-formfu-perl libmoose-perl \
- libregexp-assemble-perl libhtml-formfu-model-dbic-perl
-
- ...
-
- sudo aptitude clean
-
-Then use the following command to install directly from CPAN the modules
-that aren't available as Debian packages:
-
- sudo cpan Catalyst::Component::InstancePerContext Catalyst::Controller::HTML::FormFu
+Source code for the tutorial in included in the F
+directory of the Tutorial Virtual machine (one subdirectory per
+chapter). There are also instructions for downloading the code in
+L.
=head1 HTML::FormFu FORM CREATION
-This section looks at how L can be used to
-add additional functionality to the manually created form from Chapter 4.
+This section looks at how L can be used to add additional
+functionality to the manually created form from
+L.
=head2 Inherit From Catalyst::Controller::HTML::FormFu
-First, change your C to inherit from
-L
-by changing the C
-This adds a new link to the bottom of the book list page that we can
-use to easily launch our HTML::FormFu-based form.
+This adds a new link to the bottom of the book list page that we can 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"
-
-Click the Submit button, and you will be returned to the Book List page
+ 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.
Also note that this implementation allows you to create books with any
-bogus information. Although we have constrained the authors with the
-drop-down list (note that this isn't bulletproof because we still have
-not prevented a user from "hacking" the form to specify other values),
-there are no restrictions on items such as the length of the title (for
-example, you can create a one-letter title) and the value of the rating
-(you can use any number you want, and even non-numeric values with
+bogus information. Although we have constrained the authors with the
+drop-down list (note that this isn't bulletproof because we still have
+not prevented a user from "hacking" the form to specify other values),
+there are no restrictions on items such as the length of the title (for
+example, you can create a one-letter title) and the value of the rating
+(you can use any number you want, and even non-numeric values with
SQLite). The next section will address this concern.
B Depending on the database you are using and how you established
@@ -297,19 +280,18 @@ performing any validation.
=head1 HTML::FormFu VALIDATION AND FILTERING
-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
-users input appropriate data (for example, that the email field of a
-form contains a valid email address). Filtering can also be used to
-remove extraneous whitespace from fields or to escape meta-characters in
-user input.
+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 users input
+appropriate data (for example, that the email field of a form contains a
+valid email address). Filtering can also be used to remove extraneous
+whitespace from fields or to escape meta-characters in user input.
=head2 Add Constraints
-Open C in your editor and update it
+Open F in your editor and update it
to match:
---
@@ -332,7 +314,7 @@ to match:
max: 40
# Override the default of 'Invalid input'
message: Length must be between 5 and 40 characters
-
+
# Another text field for the numeric rating
- type: Text
name: rating
@@ -356,7 +338,7 @@ to match:
min: 1
max: 5
message: "Must be between 1 and 5."
-
+
# Add a select list for the author selection. Note that we will
# dynamically fill in all the authors from the controller but we
# could manually set items in the select by adding this YAML code:
@@ -377,26 +359,26 @@ to match:
constraints:
# Make sure it's a number
- Integer
-
+
# The submit button
- type: Submit
name: submit
value: Submit
-
+
# Global filters and constraints.
constraints:
- # The user cannot leave any fields blank
- - Required
- # If not all fields are required, move the Required constraint to the
- # fields that are
+ # The user cannot leave any fields blank
+ - Required
+ # If not all fields are required, move the Required constraint to the
+ # fields that are
filter:
- # Remove whitespace at both ends
- - TrimEdges
- # Escape HTML characters for safety
- - HTMLEscape
+ # Remove whitespace at both ends
+ - TrimEdges
+ # Escape HTML characters for safety
+ - HTMLEscape
-B Copying and pasting YAML from perl documentation is sometimes
-tricky. See the L section of
+B Copying and pasting YAML from Perl documentation is sometimes
+tricky. See the L section of
this document for a more foolproof config format.
The main changes are:
@@ -406,69 +388,67 @@ The main changes are:
=item *
The C