[pve-devel] KVComboBox validator

Dietmar Maurer dietmar at proxmox.com
Tue Nov 15 09:12:03 CET 2016


While running automated test, I saw that KVComboBox does not
validate anything! I wonder if this makes sense?


diff --git a/www/manager6/form/KVComboBox.js b/www/manager6/form/KVComboBox.js
index beafed0..9dba021 100644
--- a/www/manager6/form/KVComboBox.js
+++ b/www/manager6/form/KVComboBox.js
@@ -33,6 +33,26 @@ Ext.define('PVE.form.KVComboBox', {
         return data;
     },

+    validator: function(val) {
+       var me = this;
+
+        if (me.editable || val === null || val === '') {
+           return true;
+       }
+
+       if (me.comboItems) {
+           if (Ext.Array.some(me.comboItems, function(el) {
+               if (el[1] === val) {
+                   return true;
+               }
+           })) {
+               return true;
+           }
+       }
+
+       return "value '" + val + "' not allowed!";
+    },
+
     initComponent: function() {
        var me = this;




More information about the pve-devel mailing list