]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
ComboGrid: fix validation for !allowBlank disabled fields
authorStefan Reiter <s.reiter@proxmox.com>
Mon, 3 Feb 2020 14:14:42 +0000 (15:14 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 5 Feb 2020 07:40:45 +0000 (08:40 +0100)
Used in "Add USB to VM" dialog for example.

This was broken before 15206214d9 "ComboGrid: fix on-load validation for blank
values" (only the one you enabled first was validated, the other always showed
as valid), and afterwards too, but in a different way (both are now immediately
marked invalid until you select and unselect them) - which is how I noticed.

With this the validation now works correctly.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
form/ComboGrid.js

index 54bc239a7d9d46d12875106991de4f4dbefa529e..9bdf7217af0943fc63929807c6c28c0d842747f8 100644 (file)
@@ -378,6 +378,13 @@ Ext.define('Proxmox.form.ComboGrid', {
        return true;
     },
 
+    // validate after enabling a field, otherwise blank fields with !allowBlank
+    // are sometimes not marked as invalid
+    setDisabled: function(value) {
+       this.callParent([value]);
+       this.validate();
+    },
+
     initComponent: function() {
        var me = this;
 
@@ -461,7 +468,7 @@ Ext.define('Proxmox.form.ComboGrid', {
                        me.setValue(def, true);
                    } else if (!me.allowBlank && !(Ext.isArray(def) ? def.length : def)) {
                        me.setValue(def);
-                       if (!me.notFoundIsValid) {
+                       if (!me.notFoundIsValid && !me.isDisabled()) {
                            me.markInvalid(me.blankText);
                        }
                    }