feat: add meta and children in form.ErrorsTree()
This commit is contained in:
parent
b4ec7c6178
commit
27b7cb63ed
1 changed files with 6 additions and 9 deletions
15
form/form.go
15
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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue