[pve-devel] applied: [PATCH widget-toolkit 1/6] ComboGrid: fix on-load validation for blank values

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jan 30 17:55:40 CET 2020


On 1/29/20 11:27 AM, Stefan Reiter wrote:
> Commit f32aa3df74 fixed marking multi-select fields with where the store
> did not contain a valid value after loading.
> 
> However, it introduced a bug for single-select fields where the value
> (before the store-load) was explicitly set to be empty (when that should
> be invalid because of allowBlank === false).
> 
> Fix the logic to correctly detect all scenarios (with def being the
> value selected before the store loaded, i.e. undefined or an empty
> array):
> 
>   !allowBlank &&
>     ( def is an array but empty || def is not an array and falsy )
> 
> Also use correct error message (localized by ExtJS itself).
> 
> Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
> ---
>  form/ComboGrid.js | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/form/ComboGrid.js b/form/ComboGrid.js
> index 0c5cf1b..54bc239 100644
> --- a/form/ComboGrid.js
> +++ b/form/ComboGrid.js
> @@ -459,10 +459,10 @@ Ext.define('Proxmox.form.ComboGrid', {
>  		    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)) {
> +		    } else if (!me.allowBlank && !(Ext.isArray(def) ? def.length : def)) {
>  			me.setValue(def);
>  			if (!me.notFoundIsValid) {
> -			    me.markInvalid(gettext('Invalid Value'));
> +			    me.markInvalid(me.blankText);
>  			}
>  		    }
>  		}
> 

applied, thanks!




More information about the pve-devel mailing list