[pve-devel] applied: [PATCH widget-toolkit 2/2] ComboGrid: correctly set/mark multiSelect fields

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Nov 25 18:44:26 CET 2019


On 11/25/19 11:04 AM, Dominik Csapak wrote:
> in fields with 'multiSelect: true', we get an array as value instead
> of a string, but a check of !![] results in true (since an array
> is an object), so we have to explicitely check for arraylength
> in 'setValue' (for correctly showing the trigger) and in the
> load handler (to not set an empty field wrongfully to invalid)
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  form/ComboGrid.js | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/form/ComboGrid.js b/form/ComboGrid.js
> index 3cc64f9..0c5cf1b 100644
> --- a/form/ComboGrid.js
> +++ b/form/ComboGrid.js
> @@ -52,7 +52,8 @@ Ext.define('Proxmox.form.ComboGrid', {
>  
>      setValue: function(value) {
>  	var me = this;
> -	me.triggers.clear.setVisible(!!value && me.allowBlank);
> +	let empty = Ext.isArray(value) ? !value.length : !value;
> +	me.triggers.clear.setVisible(!empty && me.allowBlank);
>  	return me.callParent([value]);
>      },
>  
> @@ -458,7 +459,7 @@ Ext.define('Proxmox.form.ComboGrid', {
>  		    if (me.autoSelect && rec && rec.data) {
>  			def = rec.data[me.valueField];
>  			me.setValue(def, true);
> -		    } else {
> +		    } else if (!me.allowBlank && ((Ext.isArray(def) && def.length) || def)) {
>  			me.setValue(def);
>  			if (!me.notFoundIsValid) {
>  			    me.markInvalid(gettext('Invalid Value'));
> 

applied, thanks!




More information about the pve-devel mailing list