[pve-devel] [PATCH pve-manager 1/2] Recheck field validation after manually enabling the input field of a ComboGrid

Emmanuel Kasper e.kasper at proxmox.com
Mon Apr 11 14:35:58 CEST 2016


Calling setDisabled(true) on a component makes it valid, but calling setDisabled(false) afterwards did not retrigger a validation check

This fixes a serious bug which was happening in the following
conditions, for instance in the template tab of LXC Wizard:
1) user selects a storage
2) this triggers a reload of a related combogrid
3) this combogrid is marked valid, although its value is empty and it had allowedBlank: false
---
 www/manager6/form/ComboGrid.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/www/manager6/form/ComboGrid.js b/www/manager6/form/ComboGrid.js
index 8d4652a..569daf3 100644
--- a/www/manager6/form/ComboGrid.js
+++ b/www/manager6/form/ComboGrid.js
@@ -242,6 +242,8 @@ Ext.define('PVE.form.ComboGrid', {
 
 	me.mon(me.store, 'beforeload', function() {
 	    if (!me.isDisabled()) {
+		// prevent user input and field validation until the store is successfully loaded
+		me.suspendEvent('validitychange');
 		me.setDisabled(true);
 		me.enableAfterLoad = true;
 	    }
@@ -255,6 +257,8 @@ Ext.define('PVE.form.ComboGrid', {
 		if (me.enableAfterLoad) {
 		    delete me.enableAfterLoad;
 		    me.setDisabled(false);
+		    me.resumeEvent('validitychange');
+		    me.isValid(); // if field was disabled then reenabled, validation status was lost
 		}
 
 		var def = me.getValue() || me.preferredValue;
-- 
2.1.4




More information about the pve-devel mailing list