[Catalyst-commits] r7509 - in
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk: .
lib/CatalystX/CRUD/Controller
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Mon Mar 17 14:57:44 GMT 2008
Author: karpet
Date: 2008-03-17 14:57:44 +0000 (Mon, 17 Mar 2008)
New Revision: 7509
Modified:
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm
Log:
bump version and add debugging method for form errors
Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes 2008-03-17 14:57:10 UTC (rev 7508)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes 2008-03-17 14:57:44 UTC (rev 7509)
@@ -35,3 +35,6 @@
0.10 29 Jan 2008
* fix bug to allow for PKs that are not serial ints
+0.11 xxx
+ * add all_form_errors() method
+
Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm 2008-03-17 14:57:10 UTC (rev 7508)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm 2008-03-17 14:57:44 UTC (rev 7509)
@@ -4,7 +4,7 @@
use NEXT;
use Carp;
-our $VERSION = '0.10';
+our $VERSION = '0.11';
=head1 NAME
@@ -70,6 +70,7 @@
$self->{_form}->clear unless $c->stash->{_form_called}++;
$self->{_form}->app($c);
}
+ $self->NEXT::form($c);
return $self->{_form};
}
@@ -84,6 +85,22 @@
return $self->form->field_names;
}
+=head2 all_form_errors
+
+Convenience method for aggregating all form errors. Returns a single
+scalar string.
+
+=cut
+
+sub all_form_errors {
+ my ( $self, $form ) = @_;
+ my @err;
+ for my $f ( $form->fields ) {
+ push( @err, $f->error ) if $f->error;
+ }
+ return join( "\n", @err );
+}
+
=head2 form_to_object( I<context> )
Overrides base method.
@@ -117,6 +134,9 @@
# return if there was a problem with any param values
unless ( $form->validate() ) {
$c->stash->{error} = $form->error; # NOT throw_error()
+ $c->log->debug(
+ "RHTMLO: form error: " . $self->all_form_errors($form) )
+ if $c->debug;
$c->stash->{template} ||= $self->default_template; # MUST specify
return 0;
}
@@ -207,8 +227,6 @@
=back
-=head1 ACKNOWLEDGEMENTS
-
=head1 COPYRIGHT & LICENSE
Copyright 2007 Peter Karman, all rights reserved.
More information about the Catalyst-commits
mailing list