X-Git-Url: https://git.decadent.org.uk/gitweb/?p=maypole.git;a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI%2FDFV.pm;h=ded183fde396e24a5c74bc98b75b9cd37ef82743;hp=a16fa30e3adea337dba6239ee6ec8b8df98a424f;hb=f59ec6e803f30a07c3d726c40fa0cffc2e669142;hpb=99967c293b1b617a0cac8126f923f6acfa2e4598 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);