From: Aaron Trevena Date: Fri, 3 Nov 2006 11:51:16 +0000 (+0000) Subject: fixed fixes to bugs in DFV model when updating and creating object X-Git-Tag: 2.12~28 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=f59ec6e803f30a07c3d726c40fa0cffc2e669142;p=maypole.git fixed fixes to bugs in DFV model when updating and creating object git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@546 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole/Model/CDBI/DFV.pm b/lib/Maypole/Model/CDBI/DFV.pm index a16fa30..ded183f 100644 --- a/lib/Maypole/Model/CDBI/DFV.pm +++ b/lib/Maypole/Model/CDBI/DFV.pm @@ -183,8 +183,14 @@ sub _do_update { } } - my $this_class_params = { map { $_ => $r->{params}{$_} } $class->columns }; - delete $this_class_params->{route_id}; + + my $this_class_params = {}; + foreach my $param ( $class->columns ) { + next if ($param eq $class->columns('Primary')); + my $value = $r->params->{$param}; + next unless (defined $value); + $this_class_params->{$param} = ( $value eq '' ) ? undef : $value; + } # update or make other related (must_have, might_have, has_many etc ) unless ($errors) { @@ -219,7 +225,15 @@ sub _do_update { sub _do_create { my ($class,$r) = @_; my $errors; - my $this_class_params = { map { $_ => $r->{params}{$_} } $class->columns }; + + my $this_class_params = {}; + foreach my $param ( $class->columns ) { + next if ($param eq $class->columns('Primary')); + my $value = $r->params->{$param}; + next unless (defined $value); + $this_class_params->{$param} = ( $value eq '' ) ? undef : $value; + } + my $obj; my $dfv_results = Data::FormValidator->check($r->{params}, $class->dfv_profile);