Added more field types to profile fields.

This commit is contained in:
JT Smith 2003-05-10 21:54:15 +00:00
parent 9b7d273b6d
commit f131a648c2
2 changed files with 7 additions and 19 deletions

View file

@ -15,6 +15,7 @@ use strict qw(vars subs);
use URI; use URI;
use WebGUI::DateTime; use WebGUI::DateTime;
use WebGUI::ErrorHandler; use WebGUI::ErrorHandler;
use WebGUI::FormProcessor;
use WebGUI::HTMLForm; use WebGUI::HTMLForm;
use WebGUI::International; use WebGUI::International;
use WebGUI::Macro; use WebGUI::Macro;
@ -88,12 +89,7 @@ sub _validateProfileData {
tie %field, 'Tie::CPHash'; tie %field, 'Tie::CPHash';
$a = WebGUI::SQL->read("select dataType,fieldName,fieldLabel,required from userProfileField"); $a = WebGUI::SQL->read("select dataType,fieldName,fieldLabel,required from userProfileField");
while (%field = $a->hash) { while (%field = $a->hash) {
if ($field{dataType} eq "date") { $data{$field{fieldName}} = WebGUI::FormProcessor::process($field{fieldName},$field{dataType});
$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}};
}
if ($field{required} && $data{$field{fieldName}} eq "") { if ($field{required} && $data{$field{fieldName}} eq "") {
$error .= '<li>'; $error .= '<li>';
$error .= eval $field{fieldLabel}; $error .= eval $field{fieldLabel};
@ -304,7 +300,7 @@ sub www_editProfile {
} else { } else {
$subtext = ""; $subtext = "";
} }
if ($method eq "select") { if ($method eq "selectList") {
# note: this big if statement doesn't look elegant, but doing regular # note: this big if statement doesn't look elegant, but doing regular
# ORs caused problems with the array reference. # ORs caused problems with the array reference.
if ($session{form}{$data{fieldName}}) { if ($session{form}{$data{fieldName}}) {

View file

@ -197,19 +197,11 @@ sub www_editProfileField {
-label=>WebGUI::International::get(474,"WebGUI/Profile"), -label=>WebGUI::International::get(474,"WebGUI/Profile"),
-value=>$data{required} -value=>$data{required}
); );
tie %hash, 'Tie::IxHash'; $f->fieldType(
%hash = ( 'text'=>WebGUI::International::get(475), -name=>"dataType",
'textarea'=>WebGUI::International::get(476), -label=>WebGUI::International::get(486),
'HTMLArea'=>WebGUI::International::get(477), -value=>[$data{dataType} || "text"]
'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->select("dataType",\%hash,WebGUI::International::get(486),[$data{dataType}]);
$f->textarea("dataValues",WebGUI::International::get(487),$data{dataValues}); $f->textarea("dataValues",WebGUI::International::get(487),$data{dataValues});
$f->textarea("dataDefault",WebGUI::International::get(488),$data{dataDefault}); $f->textarea("dataDefault",WebGUI::International::get(488),$data{dataDefault});
tie %hash, 'Tie::CPHash'; tie %hash, 'Tie::CPHash';