From 7ced3abd895807dc5bcf0c0f9c3bcccbe501c2e3 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Wed, 8 Oct 2025 15:59:36 +0530 Subject: [PATCH] mgr/dashboard: support custom validator messages in inline edit we can add custom messages to the customTemplate like ``` name: $localize`Name`, prop: 'name', flexGrow: 2, cellTemplate: this.removingStatTpl, cellTransformation: CellTemplate.editing, customTemplateConfig: { validators: [Validators.required, Validators.pattern(/^[A-Za-z ]+$/)], errorMessages: { required: $localize`This field is required.`, pattern: $localize`The field format is invalid.` } } }, ``` also extend support for async validator Signed-off-by: Nizamudeen A --- .../app/shared/datatable/table/table.component.html | 12 ++++++------ .../app/shared/datatable/table/table.component.ts | 8 +++++++- .../src/app/shared/enum/cell-template.enum.ts | 7 ++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html index 849f02be658..8f04b99958c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html @@ -426,12 +426,12 @@ [invalid]="formGroup.controls[row?.[identifier] + '-' + column?.prop]?.invalid && formGroup.controls[row?.[identifier] + '-' + column?.prop]?.dirty"> - - This field is required. - - - The field format is invalid. - + @for (errorKey of formGroup?.get(row?.[identifier] + '-' + column?.prop)?.errors | keyvalue; track $index) { + @if (formGroup?.showError(row?.[identifier] + '-' + column?.prop, formDir, errorKey.key)) { + + {{ column.customTemplateConfig?.errorMessages?.[errorKey.key] || ('Invalid ' + column.name) }} + + }}