fixed some data entry bugs.

This commit is contained in:
JT Smith 2003-05-25 17:36:20 +00:00
parent 3d7d8dc0a7
commit 3ce64fc0d5
5 changed files with 27 additions and 23 deletions

View file

@ -418,16 +418,12 @@ An array reference of field types to be displayed. The field names are the names
=item value
The default value(s) for this form element. This should be passed as an array reference.
The default value for this form element.
=item size
The number of characters tall this form element should be. Defaults to "1".
=item multiple
A boolean value for whether this select list should allow multiple selections. Defaults to "0".
=item extras
If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows:
@ -445,7 +441,7 @@ sub fieldType {
# without adult supervision. =) It was done this way because a huge
# if/elsif construct executes much more quickly than a bunch of
# unnecessary database hits.
my @types = qw(dateTime time zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkboxList);
my @types = qw(dateTime time zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkList);
$_[0]->{types} = \@types unless ($_[0]->{types});
foreach $type (@{$_[0]->{types}}) {
if ($type eq "text") {
@ -474,7 +470,7 @@ sub fieldType {
$hash{selectList} = WebGUI::International::get(484);
} elsif ($type eq "radioList") {
$hash{radioList} = WebGUI::International::get(942);
} elsif ($type eq "checkboxList") {
} elsif ($type eq "checkList") {
$hash{checkboxList} = WebGUI::International::get(941);
} elsif ($type eq "zipcode") {
$hash{zipcode} = WebGUI::International::get(944);
@ -482,11 +478,15 @@ sub fieldType {
$hash{checkbox} = WebGUI::International::get(943);
}
}
# This is a hack for reverse compatibility with a bug where this field used to allow an array ref.
my $value = $_[0]->{value};
unless ($value eq "ARRAY") {
$value = [$value];
}
return selectList({
options=>\%hash,
name=>$_[0]->{name},
value=>$_[0]->{value},
multiple=>$_[0]->{multiple},
extras=>$_[0]->{extras},
size=>$_[0]->{size}
});

View file

@ -89,7 +89,7 @@ sub checkbox {
#-------------------------------------------------------------------
=head2 checkboxList ( name )
=head2 checkList ( name )
Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar.
@ -103,7 +103,7 @@ The name of the form variable to retrieve.
=cut
sub checkboxList {
sub checkList {
return selectList($_[0]);
}
@ -204,7 +204,7 @@ sub email {
=head2 fieldType ( name )
Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar. Defautls to "text".
Returns a field type. Defaults to "text".
=over
@ -217,7 +217,7 @@ The name of the form variable to retrieve.
=cut
sub fieldType {
return (selectList($_[0]) || "text");
return ($session{form}{$_[0]} || "text");
}

View file

@ -621,7 +621,7 @@ sub email {
#-------------------------------------------------------------------
=head2 fieldType ( name, types [ label, value, size, multiple, extras, subtext, uiLevel ] )
=head2 fieldType ( name, types [ label, value, size, extras, subtext, uiLevel ] )
Adds a field type select list field to this form. This is primarily useful for building dynamic form builders.
@ -641,16 +641,12 @@ The left column label for this form row.
=item value
The default value(s) for this form element. This should be passed as an array reference.
The default value for this form element.
=item size
The number of characters tall this form element should be. Defaults to "1".
=item multiple
A boolean value for whether this select list should allow multiple selections. Defaults to "0".
=item extras
If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows:

View file

@ -44,19 +44,19 @@ sub _createField {
if ($data->{type} eq "checkbox") {
$param{value} = ($data->{defaultValue} =~ /checked/i) ? 1 : "";
}
if (isIn($data->{type},qw(selectList checkboxList))) {
if (isIn($data->{type},qw(selectList checkList))) {
my @defaultValues;
if ($session{form}{$param{name}}) {
@defaultValues = $session{cgi}->param($param{name});
} else {
foreach (split(/\n/, $data->{defaultValue})) {
foreach (split(/\n/, $data->{value})) {
s/\s+$//; # remove trailing spaces
push(@defaultValues, $_);
}
}
$param{value} = \@defaultValues;
}
if (isIn($data->{type},qw(selectList checkboxList radioList))) {
if (isIn($data->{type},qw(selectList checkList radioList))) {
delete $param{size};
my %options;
tie %options, 'Tie::IxHash';
@ -431,12 +431,14 @@ sub www_editField {
$f->textarea(
-name=>"possibleValues",
-label=>WebGUI::International::get(24,$_[0]->get("namespace")),
-value=>$field{possibleValues}
-value=>$field{possibleValues},
-subtext=>'<br>'.WebGUI::International::get(85,$_[0]->get("namespace"))
);
$f->textarea(
-name=>"defaultValue",
-label=>WebGUI::International::get(25,$_[0]->get("namespace")),
-value=>$field{defaultValue}
-value=>$field{defaultValue},
-subtext=>'<br>'.WebGUI::International::get(85,$_[0]->get("namespace"))
);
if ($session{form}{fid} eq "new") {
$f->whatNext(