fix allowEmpty and bugs it caused
This commit is contained in:
parent
a829304bae
commit
7f2b6dfc83
4 changed files with 15 additions and 12 deletions
|
|
@ -2340,7 +2340,7 @@ sub update {
|
||||||
# next unless (exists $properties->{$property} || exists $definition->{properties}{$property}{defaultValue});
|
# next unless (exists $properties->{$property} || exists $definition->{properties}{$property}{defaultValue});
|
||||||
# skip a property unless it was specified to be set by the properties field
|
# skip a property unless it was specified to be set by the properties field
|
||||||
next unless (exists $properties->{$property});
|
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
|
# skip a property if it has the display only flag set
|
||||||
next if ($propertyDefinition->{displayOnly});
|
next if ($propertyDefinition->{displayOnly});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ sub definition {
|
||||||
},
|
},
|
||||||
feedHeaderLinks => {
|
feedHeaderLinks => {
|
||||||
fieldType => "checkList",
|
fieldType => "checkList",
|
||||||
|
allowEmpty => 1,
|
||||||
defaultValue => "rss\natom",
|
defaultValue => "rss\natom",
|
||||||
tab => "rss",
|
tab => "rss",
|
||||||
options => do {
|
options => do {
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,9 @@ sub definition {
|
||||||
idPrefix=>{
|
idPrefix=>{
|
||||||
defaultValue=>undef
|
defaultValue=>undef
|
||||||
},
|
},
|
||||||
|
allowEmpty=>{
|
||||||
|
defaultValue => 0,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return $definition;
|
return $definition;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ sub getValue {
|
||||||
@values = $self->session->form->param($self->get("name"));
|
@values = $self->session->form->param($self->get("name"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scalar @values < 1) {
|
if (scalar @values < 1 && ! $self->get('allowEmpty')) {
|
||||||
@values = $self->getDefaultValue;
|
@values = $self->getDefaultValue;
|
||||||
}
|
}
|
||||||
return wantarray ? @values : join("\n",@values);
|
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 {
|
sub getOriginalValue {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my @values = ();
|
my @values = ();
|
||||||
foreach my $value ($self->get("value")) {
|
my $value = $self->get("value");
|
||||||
if (scalar @values < 1 && defined $value) {
|
if (defined $value) {
|
||||||
if (ref $value eq "ARRAY") {
|
if (ref $value eq "ARRAY") {
|
||||||
@values = @{$value};
|
@values = @{$value};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$value =~ s/\r//g;
|
$value =~ s/\r//g;
|
||||||
@values = split "\n", $value;
|
@values = split "\n", $value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (@values) {
|
if (@values || ($self->get('allowEmpty') && defined $value) ) {
|
||||||
return wantarray ? @values : join("\n",@values);
|
return wantarray ? @values : join("\n",@values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue