X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI%2FDFV.pm;h=7848759d610a72bc97711b175af01bd196d41704;hb=bd6da5dd49b9a50d49098f97278e4b440cb17bd9;hp=a16fa30e3adea337dba6239ee6ec8b8df98a424f;hpb=99967c293b1b617a0cac8126f923f6acfa2e4598;p=maypole.git diff --git a/lib/Maypole/Model/CDBI/DFV.pm b/lib/Maypole/Model/CDBI/DFV.pm index a16fa30..7848759 100644 --- a/lib/Maypole/Model/CDBI/DFV.pm +++ b/lib/Maypole/Model/CDBI/DFV.pm @@ -152,10 +152,6 @@ sub do_edit : Exported { if (ref $errors) { # pass errors to template $r->template_args->{errors} = $errors; - foreach my $error (keys %$errors) { - $r->template_args->{errors}{ucfirst($error)} = $errors->{$error} - } - # Set it up as it was: $r->template_args->{cgi_params} = $r->params; $r->template("edit"); @@ -183,8 +179,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 +221,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);