From f131a648c2bb66eb43179ac12e0627ff0d60494d Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 10 May 2003 21:54:15 +0000 Subject: [PATCH] Added more field types to profile fields. --- lib/WebGUI/Operation/Account.pm | 10 +++------- lib/WebGUI/Operation/ProfileSettings.pm | 16 ++++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/WebGUI/Operation/Account.pm b/lib/WebGUI/Operation/Account.pm index aa3795bbd..0d41f4a0b 100644 --- a/lib/WebGUI/Operation/Account.pm +++ b/lib/WebGUI/Operation/Account.pm @@ -15,6 +15,7 @@ use strict qw(vars subs); use URI; use WebGUI::DateTime; use WebGUI::ErrorHandler; +use WebGUI::FormProcessor; use WebGUI::HTMLForm; use WebGUI::International; use WebGUI::Macro; @@ -88,12 +89,7 @@ sub _validateProfileData { tie %field, 'Tie::CPHash'; $a = WebGUI::SQL->read("select dataType,fieldName,fieldLabel,required from userProfileField"); while (%field = $a->hash) { - if ($field{dataType} eq "date") { - $data{$field{fieldName}} = WebGUI::DateTime::setToEpoch($session{form}{$field{fieldName}}); - $session{form}{$field{fieldName}} = $data{$field{fieldName}}; - } elsif (exists $session{form}{$field{fieldName}}) { - $data{$field{fieldName}} = $session{form}{$field{fieldName}}; - } + $data{$field{fieldName}} = WebGUI::FormProcessor::process($field{fieldName},$field{dataType}); if ($field{required} && $data{$field{fieldName}} eq "") { $error .= '
  • '; $error .= eval $field{fieldLabel}; @@ -304,7 +300,7 @@ sub www_editProfile { } else { $subtext = ""; } - if ($method eq "select") { + if ($method eq "selectList") { # note: this big if statement doesn't look elegant, but doing regular # ORs caused problems with the array reference. if ($session{form}{$data{fieldName}}) { diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index 74496835d..94cb83f08 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -197,19 +197,11 @@ sub www_editProfileField { -label=>WebGUI::International::get(474,"WebGUI/Profile"), -value=>$data{required} ); - tie %hash, 'Tie::IxHash'; - %hash = ( 'text'=>WebGUI::International::get(475), - 'textarea'=>WebGUI::International::get(476), - 'HTMLArea'=>WebGUI::International::get(477), - 'url'=>WebGUI::International::get(478), - 'date'=>WebGUI::International::get(479), - 'email'=>WebGUI::International::get(480), - 'phone'=>WebGUI::International::get(481), - 'integer'=>WebGUI::International::get(482), - 'yesNo'=>WebGUI::International::get(483), - 'select'=>WebGUI::International::get(484) + $f->fieldType( + -name=>"dataType", + -label=>WebGUI::International::get(486), + -value=>[$data{dataType} || "text"] ); - $f->select("dataType",\%hash,WebGUI::International::get(486),[$data{dataType}]); $f->textarea("dataValues",WebGUI::International::get(487),$data{dataValues}); $f->textarea("dataDefault",WebGUI::International::get(488),$data{dataDefault}); tie %hash, 'Tie::CPHash';