EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
array field validate item not entered
Yuri Kuznetsove57018732fa1
diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.jsonindex a05a720b07..a1d2496662 100644--- a/application/Espo/Resources/i18n/en_US/Global.json+++ b/application/Espo/Resources/i18n/en_US/Global.json@@ -367,6 +367,7 @@"fieldExceedsMaxCount": "Count exceeds max allowed {maxCount}","barcodeInvalid": "{field} is not valid {type}","arrayItemMaxLength": "Item shouldn't be longer than {max} characters",+ "arrayInputNotEmpty": "Item is entered but not added","resetPreferencesDone": "Preferences has been reset to defaults","confirmation": "Are you sure?","unlinkAllConfirmation": "Are you sure you want to unlink all related records?",diff --git a/client/src/views/fields/array.js b/client/src/views/fields/array.jsindex b00f41dc76..58f345912d 100644--- a/client/src/views/fields/array.js+++ b/client/src/views/fields/array.js@@ -227,6 +227,10 @@ class ArrayFieldView extends BaseFieldView {if (this.params.allowCustomOptions || !this.params.options) {this.allowCustomOptions = true;}++ if (this.type === 'array') {+ this.validations.push('noInputValue')+ }}focusOnElement() {@@ -905,6 +909,33 @@ class ArrayFieldView extends BaseFieldView {});});}++ // noinspection JSUnusedGlobalSymbols+ /**+ * @protected+ * @return {boolean}+ */+ validateNoInputValue() {+ if (!this.element) {+ return false;+ }++ const input = this.element.querySelector('input.select');++ if (!(input instanceof HTMLInputElement)) {+ return false;+ }++ if (!input.value) {+ return false;+ }++ const message = this.translate('arrayInputNotEmpty', 'messages');++ this.showValidationMessage(message, 'input.select');++ return true;+ }}export default ArrayFieldView;