* All apps: fix unable to remove last value from multiselect

This commit is contained in:
Ralf Becker 2015-04-03 12:47:29 +00:00
parent dc43139c6c
commit 4eea57c8a8
2 changed files with 3 additions and 2 deletions

View File

@ -519,7 +519,7 @@ class etemplate_new extends etemplate_widget_template
{ {
if (!is_array($v) || !isset($old[$k]) || // no array or a new array if (!is_array($v) || !isset($old[$k]) || // no array or a new array
isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]) || // or no associative array, eg. selecting multiple accounts isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]) || // or no associative array, eg. selecting multiple accounts
is_array($v) && count($v) == 0 && is_array($old[$k])) // Empty array replacing non-empty is_array($v) && count($v) == 0) // Empty array replacing non-empty
{ {
$old[$k] = $v; $old[$k] = $v;
} }

View File

@ -725,11 +725,12 @@ var et2_selectbox = et2_inputWidget.extend(
var value = []; var value = [];
jQuery("input:checked",this.multiOptions).each(function(){value.push(this.value);}); jQuery("input:checked",this.multiOptions).each(function(){value.push(this.value);});
// we need to return null for no value instead of empty array, which gets overwritten by preserved value on server-side // we need to return null for no value instead of empty array, which gets overwritten by preserved value on server-side
this.value = value.length > 0 ? value : null; this.value = value;
} }
else else
{ {
this.value = this._super.apply(this, arguments); this.value = this._super.apply(this, arguments);
if (this.value === null) this.value = []; // do NOT return null, as it does not get transmitted to server
} }
return this.value; return this.value;
}, },