Catalyst::Plugin::CRUD::DBIC - CRUD (create/read/update/delete) Plugin for DBIx::Class
# MyApp/lib/MyApp.pm package MyApp; use Catalyst qw/-Debug CRUD::DBIC/; 1; # MyApp/lib/MyApp/Controller/User.pm package MyApp::Controller::User; use base 'Catalyst::Controller'; use Class::Trigger; sub config { my ( $self, $c ) = @_; my $hash = { 'name' => 'user', 'model' => 'DBIC::UserMaster', 'primary' => 'id', 'columns' => [qw(name phone mail)], 'default' => '/user/list', 'template' => { 'prefix' => 'template/user/', 'create' => 'create.html', 'read' => 'read.html', 'update' => 'update.html', 'delete' => 'delete.html', 'list' => 'list.html' }, }; return $hash; } sub create : Local { my ( $self, $c ) = @_; $c->create($self); } 1; <!-- MyApp/root/template/user/create.html --> <html> <body> <h1>Create New User</h1> <form name="user" method="post" action="/user/create"> <table> <tr> <td>User Name</td><td><input type="text" name="name" value="[% c.req.param('name') %]"></td> </tr> <tr> <td>User Phone</td><td><input type="text" name="phone" value="[% c.req.param('phone') %]"></td> </tr> <tr> <td>User Email</td><td><input type="text" name="mail" value="[% c.req.param('mail') %]"></td> </tr> </table> </form> </body> </html>
This module provides CRUD (create/read/update/delete) action using with DBIx::Class.
create: insert new record read: find record update: update record delete: delete record list: find all records
None by default.
create action.
if $c->stash->{create}->{error} is 1, then do not insert new recoed.
triggers:
$self->call_trigger( 'input_before', $c ); $self->call_trigger( 'create_before', $c, $hash ); $self->call_trigger( 'create_after', $c, $model );
read action.
$self->call_trigger( 'read_before', $c );
update action.
if $c->stash->{update}->{error} is 1, then do not update recoed.
$self->call_trigger( 'input_before', $c ); $self->call_trigger( 'update_before', $c, $model ); $self->call_trigger( 'update_after', $c, $model );
delete action.
if $c->stash->{update}->{error} is 1, then do not delete recoed.
$self->call_trigger( 'delete_before', $c, $model ); $self->call_trigger( 'delete_after', $c );
list action.
$self->call_trigger( 'list_before', $c );
Mention other useful documentation such as the documentation of related modules or operating system documentation (such as man pages in UNIX), or any relevant external documentation such as RFCs or standards.
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
Jun Shimizu, <bayside@cpan.org>
Copyright (C) 2006 by Jun Shimizu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.
To install Catalyst::Plugin::CRUD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::CRUD
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::CRUD
For more information on module installation, please visit the detailed CPAN module installation guide.