From: Thomas Lamprecht Date: Mon, 7 Jun 2021 16:03:25 +0000 (+0200) Subject: combo grid: load: rework auto-selection and validity logic X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=585f3c31e753bc90fa82de800083f5a0a89ba032;p=proxmox-widget-toolkit.git combo grid: load: rework auto-selection and validity logic We do not want to trigger an autoSelect if there's a value set, even if it isn't found in the store, as that hides the fact that an (now) invalid valid is configured from the user, which can be confusing if something is not working, as when editing an object it seems like a valid value is selected. Further, if a value is set we mark the field as invalid from the start, at least if it's neither disabled nor allowed to have a value which is does not exists in the backing store. Signed-off-by: Thomas Lamprecht --- diff --git a/src/form/ComboGrid.js b/src/form/ComboGrid.js index af04559..923a55a 100644 --- a/src/form/ComboGrid.js +++ b/src/form/ComboGrid.js @@ -445,15 +445,19 @@ Ext.define('Proxmox.form.ComboGrid', { } if (!found) { - let rec = me.store.first(); - if (me.autoSelect && rec && rec.data) { - def = rec.data[me.valueField]; - me.setValue(def, true); - } else if (!me.allowBlank && !(Ext.isArray(def) ? def.length : def)) { - me.setValue(def); - if (!me.notFoundIsValid && !me.isDisabled()) { - me.markInvalid(me.blankText); + if (!(Ext.isArray(def) ? def.length : def)) { + let rec = me.store.first(); + if (me.autoSelect && rec && rec.data) { + def = rec.data[me.valueField]; + me.setValue(def, true); + } else if (!me.allowBlank) { + me.setValue(def); + if (!me.isDisabled()) { + me.markInvalid(me.blankText); + } } + } else if (!me.notFoundIsValid && !me.isDisabled()) { + me.markInvalid(gettext('Invalid Value')); } } } else {