From 13d7ebc8377f1a4c620c37ee8df939d597d5f682 Mon Sep 17 00:00:00 2001 From: Richard Nutt Date: Tue, 4 Aug 2020 16:17:07 +0200 Subject: [PATCH] fix(*): display all errors of invalid fields upon pressing save fixes #476 (PR #477) --- .../children/child-details/child-details.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/child-dev-project/children/child-details/child-details.component.ts b/src/app/child-dev-project/children/child-details/child-details.component.ts index 2d82f42628..19162649dc 100644 --- a/src/app/child-dev-project/children/child-details/child-details.component.ts +++ b/src/app/child-dev-project/children/child-details/child-details.component.ts @@ -193,7 +193,10 @@ export class ChildDetailsComponent implements OnInit { } save() { + // errors regarding invalid fields wont be displayed unless marked as touched + this.form.markAllAsTouched(); this.validateForm = true; + if (this.form.valid) { this.assignFormValuesToChild(this.child, this.form); @@ -214,7 +217,9 @@ export class ChildDetailsComponent implements OnInit { ); } else { const invalidFields = this.getInvalidFields(this.form); - this.alertService.addDanger("Form invalid, required fields missing"); + this.alertService.addDanger( + "Form invalid, required fields (" + invalidFields + ") missing" + ); } }