GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Catalyst::Enzyme::CRUD::Controller(3) User Contributed Perl Documentation Catalyst::Enzyme::CRUD::Controller(3)

Catalyst::Enzyme::CRUD::Controller - CRUD Controller Base Class with CRUD support

See Catalyst::Enzyme

The model class, overloaded by you in each controller class to return the actual class name for the Model this controller should handle.

So in your Controller classes, something like this is recommended:

    sub model_class {
        return("BookShelf::Model::BookShelfDB::Genre");
    }

These are the default CRUD actions.

You should read the source so you know what the actions do, and how you can adjust or block them in your own code.

They also deal with form validation, messages, and errors in a certain way that you could use (or not, you may have a better way) in your own Controller actions.

Set up the default model and class for this Controller

Set the current Controller and it's Model class (and the Model's configuration using the model_class() ).

Point $self->crud_config to the Model's config->{crud}. Set crud_config keys:

 model_class
 model
 moniker (default)
 rows_per_page (default 20)
 column_monikers (default)

Set stash keys:

 crud (to the crud_config)
 controller_namespace (to the Controller's namespace)
 uri_for_list (to a version that accepts array refs from TT)

Return 1.

Usage
This action is automatically called by the "auto" action.

This means that if the user invokes an action in a Controller, the set_crud_controller is called properly and that Controller's Model class is used. No need to do anything.

If you forward between actions in the same Controller, the same Model class should be used, so no need to do anything.

But if you forward to an action in a different Controller, you need to tell Enzyme to start using the new Model class first. So, going from e.g. the Book Controller to a Genre action, you need to:

    $c->forward("/genre/set_crud_controller");
    $c->forward("/genre/add");
    

Forward to list.

Display list template

Select a row and display view template.

Display add template

Add a new row and redirect to list.

Display edit template.

Edit a row and redirect to edit.

Display delete template.

Destroy row and forward to list.

Return hash ref with a default Data::FormValidator config.

Return hash ref with config values form the Model class' config->{crud} (so model_class needs to be set).

Return either the current model class, or (if $rows_per_page > 0) a pager for the current model class. $page indicates which page to display in the pager (default to the first page).

Assign the pager to $c->stash->{pager}.

The Model class (or it's base class) must "use Class::DBI::Pager".

Retrieve object with $id and set the $template. Suitable to call like this in an action (nothing else is needed):

    sub edit : Local {
       shift->template_with_item("edit.tt", @_);
    }

Johan Lindstrom <johanl ÄT cpan.org>

This library is free software . You can redistribute it and/or modify it under the same terms as perl itself.

Hey! The above document had some coding errors, which are explained below:
Around line 374:
Non-ASCII character seen before =encoding in 'ÄT'. Assuming CP1252
2006-01-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.