X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FBasicCRUD.pod;h=72be8e15587ef8c513cf3c64ee77c5cf25e0cfa5;hp=dcc3ade3659829fe927050aef667a5c54da93424;hb=7edc54841a8a242568f86b548bf05ebe2400de80;hpb=14e5ed66dcd737f2210d8d7d8c22e3c474992846 diff --git a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod index dcc3ade..72be8e1 100644 --- a/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod @@ -66,9 +66,17 @@ focus on the Create and Delete aspects of CRUD. More advanced capabilities, including full Update functionality, will be addressed in Part 9. +Although this part of the tutorial will show you how to build CRUD +functionality yourself, another option is to use a "CRUD builder" type +of tool to automate the process. You get less control, but it's quick +and easy. For example, see +L, +L, and +L. + You can checkout the source code for this example from the catalyst subversion repository as per the instructions in -L +L. =head1 FORMLESS SUBMISSION @@ -164,7 +172,7 @@ Edit C and then enter: [% # Provide a link back to the list page -%] [% # 'uri_for()' builds a full URI; e.g., 'http://localhost:3000/books/list' -%] -

Return to list

+

Return to list

[% # Try out the TT Dumper (for development only!) -%]
@@ -172,22 +180,20 @@ Edit C and then enter:
     [% Dumper.dump(book) %]
     
-The TT C directive allows access to a variety of plugin modules (TT -plugins, that is, not Catalyst plugins) to add extra functionality to -the base TT capabilities. Here, the plugin allows L -"pretty printing" of objects and variables. Other than that, the rest -of the code should be familiar from the examples in Part 3. +The TT C directive allows access to a variety of plugin modules +(TT plugins, that is, not Catalyst plugins) to add extra functionality +to the base TT capabilities. Here, the plugin allows +L "pretty printing" of objects and +variables. Other than that, the rest of the code should be familiar +from the examples in Part 3. -B As mentioned earlier, the C view -class created by TTSite redefines the name used to access the Catalyst -context object in TT templates from the usual C to C. =head2 Try the C Feature If the application is still running from before, use C to kill it. Then restart the server: - $ script/myapp_server.pl + $ DBIC_TRACE=1 script/myapp_server.pl Note that new path for C appears in the startup debug output. @@ -218,9 +224,9 @@ The C statements are obviously adding the book and linking it to the existing record for Richard Stevens. The C Rating: @@ -278,6 +285,7 @@ Open C in your editor and enter: Note that we have specified the target of the form data as C, the method created in the section that follows. + =head2 Add a Method to Process Form Values and Update Database Edit C and add the following method to @@ -326,7 +334,7 @@ it. Then restart the server: Point your browser to L and enter "TCP/IP Illustrated, Vol 3" for the title, a rating of 5, and an -author ID of 4. You should then be forwarded to the same +author ID of 4. You should then see the output of the same C template seen in earlier examples. Finally, click "Return to list" to view the full list of books. @@ -380,7 +388,7 @@ and 2) the four lines for the Delete link near the bottom). [% # Add a link to delete a book %] - Delete + Delete [% END -%] @@ -390,12 +398,13 @@ The additional code is obviously designed to add a new column to the right side of the table with a C "button" (for simplicity, links will be used instead of full HTML buttons). + =head2 Add a Delete Action to the Controller Open C in your editor and add the following method: - =head2 delete + =head2 delete Delete a book @@ -530,18 +539,23 @@ C method to match the following: This modification simply leverages the ability of C to include an arbitrary number of name/value pairs in a hash reference. Next, we -need to update C to handle C as a +need to update C to handle C as a query parameter: - - + ...
- [% status_msg || Catalyst.request.params.status_msg %] - [% error_msg %] - [% content %] -
- - + [%# Status and error messages %] + [% status_msg || c.request.params.status_msg %] + [% error_msg %] + [%# This is where TT will stick all of your template's contents. -%] + [% content %] + + ... + +Although the sample above only shows the C div, leave the +rest of the file intact -- the only change we made to the C +was to add "C<|| c.request.params.status_msg>" to the +Cspan class="message"E> line. =head2 Try the Delete and Redirect With Query Param Logic @@ -567,8 +581,8 @@ 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). +(L).