fix allowEmpty and bugs it caused

This commit is contained in:
Graham Knop 2009-04-03 00:40:23 +00:00
parent a829304bae
commit 7f2b6dfc83
4 changed files with 15 additions and 12 deletions

View file

@ -2340,7 +2340,7 @@ sub update {
# next unless (exists $properties->{$property} || exists $definition->{properties}{$property}{defaultValue});
# skip a property unless it was specified to be set by the properties field
next unless (exists $properties->{$property});
my $propertyDefinition = $definition->{property}{$property};
my $propertyDefinition = $definition->{properties}{$property};
# skip a property if it has the display only flag set
next if ($propertyDefinition->{displayOnly});

View file

@ -115,6 +115,7 @@ sub definition {
},
feedHeaderLinks => {
fieldType => "checkList",
allowEmpty => 1,
defaultValue => "rss\natom",
tab => "rss",
options => do {

View file

@ -196,6 +196,9 @@ sub definition {
idPrefix=>{
defaultValue=>undef
},
allowEmpty=>{
defaultValue => 0,
},
});
return $definition;
}

View file

@ -220,7 +220,7 @@ sub getValue {
@values = $self->session->form->param($self->get("name"));
}
}
if (scalar @values < 1) {
if (scalar @values < 1 && ! $self->get('allowEmpty')) {
@values = $self->getDefaultValue;
}
return wantarray ? @values : join("\n",@values);
@ -262,18 +262,17 @@ Returns the either the "value" ore "defaultValue" passed in to the object in tha
sub getOriginalValue {
my $self = shift;
my @values = ();
foreach my $value ($self->get("value")) {
if (scalar @values < 1 && defined $value) {
if (ref $value eq "ARRAY") {
@values = @{$value};
}
else {
$value =~ s/\r//g;
@values = split "\n", $value;
}
my $value = $self->get("value");
if (defined $value) {
if (ref $value eq "ARRAY") {
@values = @{$value};
}
else {
$value =~ s/\r//g;
@values = split "\n", $value;
}
}
if (@values) {
if (@values || ($self->get('allowEmpty') && defined $value) ) {
return wantarray ? @values : join("\n",@values);
}