[Catalyst-commits] r7598 - 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 Apr 7 20:53:40 BST 2008
Author: karpet
Date: 2008-04-07 20:53:39 +0100 (Mon, 07 Apr 2008)
New Revision: 7598
Modified:
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Makefile.PL
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm
Log:
* add all_form_errors() method
* now passes $obj instead of $obj->delegate to form/object init
methods. This relies on the AUTOLOAD magic in CX::CRUD::Object to work
correctly, but it means that authors can have more methods than just the
c/r/u/d types on their Object wrappers (as CX::CRUD::Object::File does).
Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes 2008-04-07 19:37:32 UTC (rev 7597)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes 2008-04-07 19:53:39 UTC (rev 7598)
@@ -37,4 +37,8 @@
0.11 xxx
* add all_form_errors() method
+ * now passes $obj instead of $obj->delegate to form/object init methods.
+ This relies on the AUTOLOAD magic in CX::CRUD::Object to work correctly,
+ but it means that authors can have more methods than just the c/r/u/d
+ types on their Object wrappers (as CX::CRUD::Object::File does).
Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Makefile.PL
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Makefile.PL 2008-04-07 19:37:32 UTC (rev 7597)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Makefile.PL 2008-04-07 19:53:39 UTC (rev 7598)
@@ -10,7 +10,7 @@
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
- 'CatalystX::CRUD' => 0.20,
+ 'CatalystX::CRUD' => 0.26,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
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-04-07 19:37:32 UTC (rev 7597)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm 2008-04-07 19:53:39 UTC (rev 7598)
@@ -94,9 +94,9 @@
sub all_form_errors {
my ( $self, $form ) = @_;
- my @err;
+ my @err = ( $form->error );
for my $f ( $form->fields ) {
- push( @err, $f->error ) if $f->error;
+ push( @err, $f->name . ': ' . $f->error ) if $f->error;
}
return join( "\n", @err );
}
@@ -120,7 +120,9 @@
my $id = $c->req->params->{$pk} || $c->stash->{object_id};
# initialize the form with the object's values
- $form->$form_meth( $obj->delegate );
+ # TODO this might not work if the delegate() does not have
+ # 1-to-1 mapping of form fields to object methods.
+ $form->$form_meth( $obj );
# set param values from request
$form->params( $c->req->params );
@@ -135,14 +137,17 @@
unless ( $form->validate() ) {
$c->stash->{error} = $form->error; # NOT throw_error()
$c->log->debug(
- "RHTMLO: form error: " . $self->all_form_errors($form) )
+ "RHTMLO: form error:\n" . $self->all_form_errors($form) )
if $c->debug;
$c->stash->{template} ||= $self->default_template; # MUST specify
return 0;
}
# re-set object's values from the now-valid form
- $form->$obj_meth( $obj->delegate );
+ # TODO this might not work if the delegate() does not have
+ # 1-to-1 mapping of form fields to object methods.
+ # this is same objection as $form_metho call above
+ $form->$obj_meth( $obj );
# set id explicitly since there's some bug
# with param() setting it in save()
More information about the Catalyst-commits
mailing list