From 6f52ff858c327e3553b8e084b18d7722379e5975 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 11 Aug 2015 22:28:00 +0000 Subject: [PATCH] Automatically expand to multiple rows if the option is set and value is multiple so we don't lose part of the value --- etemplate/js/et2_widget_selectbox.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 21df559b2c..e437d9aef0 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -436,7 +436,7 @@ var et2_selectbox = et2_inputWidget.extend( set_value: function(_value) { if (typeof _value == "number") _value = ""+_value; // convert to string for consitent matching - if(typeof _value == "string" && this.options.multiple && _value.match(this._is_multiple_regexp) !== null) + if(typeof _value == "string" && (this.options.multiple || this.options.expand_multiple_rows) && _value.match(this._is_multiple_regexp) !== null) { _value = _value.split(','); } @@ -465,6 +465,12 @@ var et2_selectbox = et2_inputWidget.extend( // Unchanged if(_value == this.value) return; } + // Auto-expand multiple if not yet turned on, and value has multiple + if(this.options.expand_multiple_rows && !this.options.multiple && jQuery.isArray(_value) && _value.length > 1) + { + this.set_multiple(true, this.options.expand_multiple_rows); + } + jQuery("option",this.input).prop("selected", false); if(typeof _value == "array") {