[Catalyst-commits] r12142 -
trunk/examples/CatalystAdvent/root/2009/pen
alexn_org at dev.catalyst.perl.org
alexn_org at dev.catalyst.perl.org
Wed Dec 2 13:55:14 GMT 2009
Author: alexn_org
Date: 2009-12-02 13:55:13 +0000 (Wed, 02 Dec 2009)
New Revision: 12142
Modified:
trunk/examples/CatalystAdvent/root/2009/pen/formhandler.pod
Log:
added autogenerated field
Modified: trunk/examples/CatalystAdvent/root/2009/pen/formhandler.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2009/pen/formhandler.pod 2009-12-02 00:16:49 UTC (rev 12141)
+++ trunk/examples/CatalystAdvent/root/2009/pen/formhandler.pod 2009-12-02 13:55:13 UTC (rev 12142)
@@ -132,6 +132,10 @@
data_type => 'text',
is_nullable => 1,
},
+ summary => {
+ data_type => 'text',
+ is_nullable => 1,
+ },
rank => {
data_type => 'decimal',
size => [3, 2],
@@ -380,6 +384,25 @@
has_field 'rank' => ( type => '+Blog::Form::Field::Rank', default => '0.00' );
+=head3 Auto-generating values
+
+In our example, the Article model has a "summary" field. We want this
+to be autogenerated ... I'm sure you can find on CPAN modules for
+doing this, and one stupid way of doing it would be to just delete the
+HTML tags and slice it to 200 chars or something.
+
+So to autogenerate the summary tag, add the following to
+C<Blog::Form::Article> ...
+
+ after 'update_model' => sub {
+ my $self = shift;
+ my $item = $self->item;
+
+ my $summary = generate_symmary($item->content);
+ $item->update({ summary => $summary })
+ if $summary;
+ };
+
=head2 Testing
And we are done. Start your development server with ...
More information about the Catalyst-commits
mailing list