fix error with empty values with multiple and non-existant data

if a value was array(null) or array(_other => null, _choices => null),
the isEmptyValue function failed.
This commit is contained in:
2016-01-01 22:24:38 +01:00
parent f145ae7f88
commit f288f67bb9
2 changed files with 68 additions and 18 deletions

View File

@@ -247,7 +247,7 @@ class CustomFieldChoice extends AbstractCustomField
return $value;
} else {
// we have a field with "allow other"
if (isset($value['_choices'])) {
if (array_key_exists('_choices', $value)) {
return $value['_choices'];
} else {
// we have a field with "multiple"
@@ -273,13 +273,17 @@ class CustomFieldChoice extends AbstractCustomField
if (is_array($value))
{
// if allow other
if (isset($value['_choices'])) {
if (array_key_exists('_choices', $value)) {
if ($value['_choices'] === NULL) {
return true;
}
return empty($value['_choices']);
} else { // we do not have 'allow other'
return empty($value);
if (count($value) === 1){
return empty($value[0]);
} else {
return empty($value);
}
}
} else {
return empty($value);