Fix a bug where List-type Forms created via DynamicField did not use default

values from the Form itself.  If you truly want a List with no defaults,
pass in an empty string on the value key in the param hash:

{ value => '' }
This commit is contained in:
Colin Kuskie 2005-12-16 19:36:59 +00:00
parent 19dba14c44
commit 7167f97a92
2 changed files with 4 additions and 4 deletions

View file

@ -114,7 +114,7 @@ sub new {
##List type forms. Historically, dynamically created forms have always ##List type forms. Historically, dynamically created forms have always
##used the default size. ##used the default size.
if ($formObj->isa('WebGUI::Form::List')) { if ($formObj->isa('WebGUI::Form::List')) {
$formObj->correctValues(); $formObj->correctValues($param->{value});
$formObj->correctOptions($param->{possibleValues}); $formObj->correctOptions($param->{possibleValues});
} }
elsif ($size) { elsif ($size) {

View file

@ -91,10 +91,10 @@ method.
=cut =cut
sub correctValues { sub correctValues {
my ($self) = @_; my ($self, $value) = @_;
return unless defined $self->{value}; return unless defined $value;
my @defaultValues; my @defaultValues;
foreach (split(/\n/, $self->{value})) { foreach (split(/\n/, $value)) {
s/\s+$//; # remove trailing spaces s/\s+$//; # remove trailing spaces
push(@defaultValues, $_); push(@defaultValues, $_);
} }