From 6ff99b15c3839566f525b8cbc64ccc810d3c67eb Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 3 Oct 2021 01:25:45 +1000 Subject: [PATCH] Clear errors once fixed --- lib/api_form.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/api_form.dart b/lib/api_form.dart index 3a917fb8..fc4b3a36 100644 --- a/lib/api_form.dart +++ b/lib/api_form.dart @@ -181,9 +181,11 @@ class APIFormField { // Extract error messages from the server response void extractErrorMessages(APIResponse response) { + dynamic errors = null; + if (isSimple) { // Simple fields are easily handled - data["errors"] = response.data[name]; + errors = response.data[name]; } else { if (parent.isNotEmpty) { dynamic parentElement = response.data[parent]; @@ -194,10 +196,12 @@ class APIFormField { } if (parentElement is Map) { - data["errors"] = parentElement[name]; + errors = parentElement[name]; } } } + + data["errors"] = errors; } // Return the error message associated with this field