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=732165ae9f80ddbb142700a9d70d865b550cdcc0;hp=bf4349d9c5cedfb428310e262c81055b13909151;hb=aeaa7db5ec678d87f39c7e27f4c1fc7a95c6af56;hpb=3ab6187c1a123983b6ae29e57f543328ce15755c diff --git a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod index bf4349d..732165a 100644 --- a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod +++ b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod @@ -59,7 +59,7 @@ L 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. +using HTML::FormFu version 0.05001. See L @@ -67,30 +67,6 @@ 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 - - =head1 HTML::FormFu FORM CREATION This section looks at how L can be used to @@ -101,14 +77,19 @@ add additional functionality to the manually created form from Chapter 4. First, change your C to inherit from L -by changing the C line from the default of: +by changing the C line from the default of: - use parent 'Catalyst::Controller'; + BEGIN {extends 'Catalyst::Controller'; } to use the FormFu base controller class: - use parent 'Catalyst::Controller::HTML::FormFu'; + 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 @@ -243,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 @@ -263,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. @@ -426,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. @@ -526,7 +502,7 @@ We use C<$id> to look up the existing book from the database. We make sure the book lookup returned a valid book. If not, we set the error message and return to the book list. - + =item * If the form has been submitted and passes validation, we skip creating a @@ -563,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 @@ -669,7 +640,7 @@ 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 -L. +L. Copyright 2006-2008, Kennedy Clark, under Creative Commons License (L).