From: Aaron Trevena Date: Sun, 15 Oct 2006 15:08:51 +0000 (+0000) Subject: DFV model mostly working with Postgres X-Git-Tag: 2.12~42 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=d4c604cd340f311044ce23c73c4321bf49553b36;p=maypole.git DFV model mostly working with Postgres git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@532 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole/Model/CDBI/DFV.pm b/lib/Maypole/Model/CDBI/DFV.pm index a6b12b3..5c7a127 100644 --- a/lib/Maypole/Model/CDBI/DFV.pm +++ b/lib/Maypole/Model/CDBI/DFV.pm @@ -204,28 +204,22 @@ sub _do_create { my ($class,$r) = @_; my $errors; my $this_class_params = { map { $_ => $r->{params}{$_} } $class->columns }; - my $dfv_results; my $obj; - if ($class->isa('Class::DBI::DFV')) { - $obj = eval { My::DBI->create( $this_class_params ) }; - $dfv_results = ($obj) ? undef : $class->dfv_results ; + my $dfv_results = Data::FormValidator->check($r->{params}, $class->dfv_profile); + if ($dfv_results->success) { + $obj = $class->create($this_class_params); } else { - $dfv_results = Data::FormValidator->check($r->{params}, $class->dfv_profile); - if ($dfv_results->success) { - $obj = $class->create($this_class_params); - } - } - - # handle dfv errors - if ( $dfv_results->has_missing ) { # missing fields - foreach my $field ( $dfv_results->missing ) { - $errors->{$field} = "$field is required"; + # handle dfv errors + if ( $dfv_results->has_missing ) { # missing fields + foreach my $field ( $dfv_results->missing ) { + $errors->{$field} = "$field is required"; + } } - } - if ( $dfv_results->has_invalid ) { # Print the name of invalid fields - foreach my $field ( $dfv_results->invalid ) { - $errors->{$field} = "$field is invalid: " . $dfv_results->invalid( $field ); + if ( $dfv_results->has_invalid ) { # Print the name of invalid fields + foreach my $field ( $dfv_results->invalid ) { + $errors->{$field} = "$field is invalid: " . $dfv_results->invalid( $field ); + } } }