X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI%2FFromCGI.pm;h=6cb95a0bce3babb9ef71dcf334c7565d87b29395;hb=refs%2Ftags%2F2.11;hp=c5ad4582ea3992dd89fa38560d7e9433fd7dcc15;hpb=833895f46fdd117b0416acff264041af2ce6f46a;p=maypole.git diff --git a/lib/Maypole/Model/CDBI/FromCGI.pm b/lib/Maypole/Model/CDBI/FromCGI.pm index c5ad458..6cb95a0 100644 --- a/lib/Maypole/Model/CDBI/FromCGI.pm +++ b/lib/Maypole/Model/CDBI/FromCGI.pm @@ -1,5 +1,6 @@ package Maypole::Model::CDBI::FromCGI; use strict; +use warnings; =head1 NAME @@ -17,7 +18,7 @@ Maypole::Model:CDBI::FromCGI - Validate form input and populate Model objects $obj = $obj->add_to_from_cgi($r); $obj = $obj->add_to_from_cgi($r, { params => {...} } ); - + # This does not work like in CDBI::FromCGI and probably never will : # $class->update_from_cgi($h, @columns); @@ -29,7 +30,6 @@ on Class::DBI::FromCGI. =cut -use warnings; # The base base model class for apps # provides good search and create functions @@ -233,7 +233,6 @@ sub add_to_from_cgi { unless ref $self; my ($errors, $validated, @created); - my $params = $opts->{params} || $r->params; $opts->{params} = $self->classify_form_inputs($params); ($validated, $errors) = $self->validate_all($r, $opts); @@ -280,12 +279,9 @@ sub validate_all { my $updating = $opts->{updating}; # Base case - validate this classes data - $opts->{all} ||= eval{ $r->config->{$self->table}{all_cols} } || - [$self->columns('All')]; - $opts->{required} ||= eval{ $r->config->{$self->table}{required_cols} } || - []; - my $ignore = $opts->{ignore} || eval{ $r->config->{$self->table}{ignore_cols} } - || []; + $opts->{all} ||= eval{ $r->config->{$self->table}{all_cols} } || [$self->columns('All')]; + $opts->{required} ||= eval { $r->config->{$self->table}{required_cols} || $self->required_columns } || []; + my $ignore = $opts->{ignore} || eval{ $r->config->{$self->table}{ignore_cols} } || []; push @$ignore, $self->primary_column->name if $updating; # Ignore hashes of foreign inputs. This takes care of required has_a's @@ -379,9 +375,7 @@ sub validate_inputs { # Required field error if ($required{$field} and !ref($value) and $err =~ /^No input for/) { - #($value eq '' or !defined $value)) $errors->{$field} = "You must supply '$field'" - #unless ($updating and$self->field; } elsif ($err) { # 1: No inupt entered