From: Nizamudeen A Date: Wed, 8 Oct 2025 10:29:36 +0000 (+0530) Subject: mgr/dashboard: support custom validator messages in inline edit X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ced3abd895807dc5bcf0c0f9c3bcccbe501c2e3;p=ceph.git 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 --- 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 849f02be658c..8f04b99958c2 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) }} + + }}