mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-24 19:53:23 +00:00
add kvcombobox validator
this enables validation of all kvcomboboxes, including multiselect Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
07a3397f4e
commit
538ebe4a84
@ -33,6 +33,28 @@ Ext.define('PVE.form.KVComboBox', {
|
||||
return data;
|
||||
},
|
||||
|
||||
validator: function(val) {
|
||||
var me = this;
|
||||
|
||||
if (me.editable || val === null || val === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (me.comboItems) {
|
||||
var values = me.multiSelect ? val.split(me.delimiter) : [val];
|
||||
var items = Ext.Array.pluck(me.comboItems, 1);
|
||||
if (Ext.Array.every(values, function(value) {
|
||||
return Ext.Array.contains(items, value);
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// returns a boolean or string
|
||||
/*jslint confusion: true */
|
||||
return "value '" + val + "' not allowed!";
|
||||
},
|
||||
|
||||
initComponent: function() {
|
||||
var me = this;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user