feat: add meta and children in form.ErrorsTree()

This commit is contained in:
Simon Vieille 2025-08-01 21:11:47 +02:00
commit 27b7cb63ed
Signed by: deblan
GPG key ID: 579388D585F70417

View file

@ -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,
}
}