From 4eea57c8a8f5021ad47c86ac789ba421dad4eb9e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 3 Apr 2015 12:47:29 +0000 Subject: [PATCH] * All apps: fix unable to remove last value from multiselect --- etemplate/inc/class.etemplate_new.inc.php | 2 +- etemplate/js/et2_widget_selectbox.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.etemplate_new.inc.php b/etemplate/inc/class.etemplate_new.inc.php index d63878b01d..5137308c45 100644 --- a/etemplate/inc/class.etemplate_new.inc.php +++ b/etemplate/inc/class.etemplate_new.inc.php @@ -519,7 +519,7 @@ class etemplate_new extends etemplate_widget_template { 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 - 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; } diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 2c17c14a64..dcdb04013a 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -725,11 +725,12 @@ var et2_selectbox = et2_inputWidget.extend( var 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 - this.value = value.length > 0 ? value : null; + this.value = value; } else { 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; },