From 27b7cb63edc9042adaf7952456b272998e7f4fa1 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 1 Aug 2025 21:11:47 +0200 Subject: [PATCH] feat: add meta and children in form.ErrorsTree() --- form/form.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/form/form.go b/form/form.go index 31bcca0..b4cfe37 100644 --- a/form/form.go +++ b/form/form.go @@ -246,17 +246,14 @@ func (f *Form) IsSubmitted() bool { } func (f *Form) ErrorsTree() map[string]any { - tree := make(map[string]any) - - if len(f.Errors) > 0 { - tree["_form"] = map[string]any{ - "errors": f.Errors, - } - } + errors := make(map[string]any) for _, field := range f.Fields { - field.ErrorsTree(tree, nil) + field.ErrorsTree(errors, nil) } - return tree + return map[string]any{ + "errors": f.Errors, + "children": errors, + } }