array field validate item not entered

This commit is contained in:
Yuri Kuznetsov
2025-03-21 09:18:46 +02:00
parent 4869d5f5b6
commit e57018732f
2 changed files with 32 additions and 0 deletions
+31
View File
@@ -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;