[Catalyst-commits] r8293 - in
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk: .
lib/CatalystX/CRUD/Controller
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Tue Aug 26 12:38:05 BST 2008
Author: karpet
Date: 2008-08-26 12:38:04 +0100 (Tue, 26 Aug 2008)
New Revision: 8293
Modified:
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm
Log:
assume no autoincrement fields in form
Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes 2008-08-26 11:32:39 UTC (rev 8292)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes 2008-08-26 11:38:04 UTC (rev 8293)
@@ -61,4 +61,7 @@
0.16 25 Aug 2008
* refactor the form_to_object() to avoid setting the PK value for a new object
+
+0.17 xxx
+ * change tact altogether in form_to_object() and assume there are no autoincrement fields in $form
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-08-26 11:32:39 UTC (rev 8292)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm 2008-08-26 11:38:04 UTC (rev 8293)
@@ -119,7 +119,9 @@
my $obj_meth = $self->init_object;
my $form_meth = $self->init_form;
- # id always comes from url but not necessarily from form
+ # id always comes from url but not necessarily from form,
+ # but in either case, $obj should already have %pk set
+ # since it was used in fetch()
my $id = $c->stash->{object_id};
my %pk = $self->get_primary_key( $c, $id );
@@ -129,30 +131,8 @@
$form->$form_meth($obj);
# set param values from request.
- # we dereference req->params in order to avoid setting $id
- # if it is an emptry string (as when submitting from create).
- # This is mostly to fix the case where the PK is an auto-increment
- # field, which we do not want to set in the object.
- my %params = %{ $c->req->params };
- if ( !$id ) {
- my $pk_field = $self->primary_key;
- if ( !ref($pk_field)
- and defined $params{$pk_field}
- and !length $params{$pk_field} )
- {
- delete $params{$pk_field};
- }
- }
- $form->params( \%params );
+ $form->params( $c->req->params );
- # set PKs specifically, in case they are not submitted
- # explicitly in form
- if ($id) {
- for my $field ( keys %pk ) {
- $form->param( $field => $pk{$field} );
- }
- }
-
# override form's values with those from params
# no_clear is important because we already initialized with object
# and we do not want to undo those mods.
@@ -174,8 +154,6 @@
# this is same objection as $form_method call above
$form->$obj_meth($obj);
- #Data::Dump::dump $obj;
-
return $obj;
}
More information about the Catalyst-commits
mailing list