Catalyst::Model::Enzyme::CRUD - CRUD Model Component
CRUD Model Component.
This is how to configure your model classes' meta data.
Some things are configured
Human readable name for this model.
E.g. "Shop Location".
Default: MyApp::Model::CDBI::ShopLocation becomes "Shop Location".
Column monikers. Hash ref with (key: column name: value: moniker).
Default: based on the column name. Override specific column names like this:
column_monikers => { __PACKAGE__->default_column_monikers, url => "URL" },
Validation rules for the data fields.
Default: no validation
Note that you need to provide the entire config hashref for Data::FormValidator.
Number of rows per page when using a pager (which will happen unless paging is disabled by setting this value is 0).
Default: 20
Let's say your Model class Book has a Foreign Key (FK) genre_id to the Genre Model class.
In the list of Books, the Genre will just be displayed with this identifier, whereas you really would like it to display the Genre name.
In the Genre model class, define the column group Stringify, like this:
__PACKAGE__->columns(Stringify => qw/ name /);
This magic is performed by Class::DBI and Class::DBI::AsForm's to_field method.
__PACKAGE__->columns(crud_view_columns => qw/ COLUMNS /);
Default: all columns.
__PACKAGE__->columns(crud_list_columns => qw/ COLUMNS /);
use Data::FormValidator::Constraints qw(:regexp_common); __PACKAGE__->columns(Stringify => qw/ url /); __PACKAGE__->config( crud => { moniker => "URL", rows_per_page => 20, data_form_validator => { optional => [ __PACKAGE__->columns ], required => [ "url" ], constraint_methods => { url => FV_URI(), }, msgs => { format => '%s', constraints => { FV_URI => "Not a URL", }, }, }, }, );
Return hash ref with the default column monikers (display names) for all columns.
You can use this to setup a Model's crud config like this:
__PACKAGE__->config( crud => { column_monikers => { __PACKAGE__->default_column_monikers, url_id => "URL" }; }, );
Return default name for $column.
Remove _id$ and ^id_.
Exemple: author_name_id --> Author Name
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.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'ÄT'. Assuming CP1252
To install Catalyst::Enzyme, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Enzyme
CPAN shell
perl -MCPAN -e shell install Catalyst::Enzyme
For more information on module installation, please visit the detailed CPAN module installation guide.