From: Simon Cozens Date: Fri, 21 May 2004 17:32:46 +0000 (+0000) Subject: Creation failure bug reported by Jesse S. X-Git-Tag: 2.10~219 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=094460849c1f2c4ec4ca0a153da2f5039eeedd40;p=maypole.git Creation failure bug reported by Jesse S. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@143 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 4321ad8..71e1a49 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -37,18 +37,21 @@ sub related { sub do_edit :Exported { my ($self, $r) = @_; my $h = CGI::Untaint->new(%{$r->{params}}); + my $creating = 0; my ($obj) = @{$r->objects || []}; if ($obj) { # We have something to edit $obj->update_from_cgi($h); } else { $obj = $self->create_from_cgi($h); + $creating++; } if (my %errors = $obj->cgi_update_errors) { # Set it up as it was: $r->{template_args}{cgi_params} = $r->{params}; $r->{template_args}{errors} = \%errors; $r->{template} = "edit"; + undef $obj if $creating; # Couldn't create } else { $r->{template} = "view"; }