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.csa...@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'));
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to