package Maypole::Model::CDBI::FromCGI;
use strict;
+use warnings;
=head1 NAME
$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);
=cut
-use warnings;
# The base base model class for apps
# provides good search and create functions
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);
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
}
-# validate_inputs undocumented. It is not yet part of the public interface.
-#=head2 validate_inputs
-#
-#$self->validate_inputs($h, $opts);
-#
-#This is the main validation method to validate inputs for a single class.
-#Most of the time you use validate_all.
-#
-# Returns validated and errors.
-# If no errors then undef in that slot.
-#
-#=cut
+
+=head2 validate_inputs
+
+$self->validate_inputs($h, $opts);
+
+This is the main validation method to validate inputs for a single class.
+Most of the time you use validate_all.
+
+Returns validated and errors.
+
+If no errors then undef in that slot.
+
+Note: This method is currently experimental (in 2.11) and may be subject to change
+without notice.
+
+=cut
sub validate_inputs {
my ($self, $h, $opts) = @_;
# 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