From 6874a5f2f93d74c7e857b4144463c10902ca1278 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 9 Mar 2006 17:41:02 +0000 Subject: [PATCH] fixing the process method to handle array returns --- lib/WebGUI/Session/Form.pm | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/WebGUI/Session/Form.pm b/lib/WebGUI/Session/Form.pm index ef8296e3f..9ed96637d 100644 --- a/lib/WebGUI/Session/Form.pm +++ b/lib/WebGUI/Session/Form.pm @@ -94,7 +94,7 @@ An alias for process() sub get { my $self = shift; - $self->process(@_); + return $self->process(@_); } #------------------------------------------------------------------- @@ -199,17 +199,25 @@ The default value for this variable. If the variable is undefined then the defau sub process { my ($self, $name, $type, $default) = @_; - my $value; $type = ucfirst($type); - $type = "Text" if ($type eq ""); - $value = $self->$type($name); - unless (defined $value) { - return $default; + return $self->param($name) if ($type eq ""); + if (wantarray) { + my @values = $self->$type($name); + if (scalar(@values) < 1 && ref $default eq "ARRAY") { + return @{$default}; + } else { + return @values; + } + } else { + my $value = $self->$type($name); + unless (defined $value) { + return $default; + } + if ($value =~ /^[\s]+$/) { + return undef; + } + return $value; } - if ($value =~ /^[\s]+$/) { - return undef; - } - return $value; } #-------------------------------------------------------------------