From 47a466a39dba6d8db9aeadbab165fa7bfa248a8b Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 15 Nov 2023 11:57:46 -0700 Subject: [PATCH] Api: Fix client side validation failure when widget value was null Happens for readonlys, disabled, selects with no valid options --- api/js/etemplate/Et2InputWidget/Et2InputWidget.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts index 4d97779928..0a1c1a1baf 100644 --- a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts +++ b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts @@ -569,11 +569,11 @@ const Et2InputWidgetMixin = >(superclass : T) validators.map(async validator => { let values = this.getValue(); - if(!Array.isArray(values)) + if(values !== null && !Array.isArray(values)) { values = [values]; } - if(!values.length) + if(values !== null && !values.length) { values = ['']; } // so required validation works @@ -588,7 +588,7 @@ const Et2InputWidgetMixin = >(superclass : T) } // Only validate if field is required, or not required and has a value // Don't bother to validate empty fields - else if(this.required || !this.required && this.getValue() != '') + else if(this.required || !this.required && this.getValue() != '' && this.getValue() !== null) { // Validate each individual item values.forEach((value) => doCheck(value, validator));