diff --git a/internal/app/action/action.go b/internal/app/action/action.go index edb738f..c30f620 100644 --- a/internal/app/action/action.go +++ b/internal/app/action/action.go @@ -248,14 +248,26 @@ func (a *Action) runAction(w http.ResponseWriter, r *http.Request) { return } - // Render the param error messages if any, using HTMX OOB - for paramName, paramError := range paramErrors { + // Render the param error messages, using HTMX OOB + errorMsgs := map[string]string{} + for _, param := range a.params { + // "" error messages have to be sent to overwrite previous values in form UI + if !strings.HasPrefix(param.Name, OPTIONS_PREFIX) { + if paramErrors[param.Name] == nil { + errorMsgs[param.Name] = "" + } else { + errorMsgs[param.Name] = fmt.Sprintf("%s", paramErrors[param.Name]) + } + } + } + + for paramName, paramError := range errorMsgs { tv := struct { Name string Message string }{ Name: paramName, - Message: fmt.Sprintf("%s", paramError), + Message: paramError, } err = a.actionTemplate.ExecuteTemplate(w, "paramError", tv) if err != nil { diff --git a/internal/app/tests/appaction_test.go b/internal/app/tests/appaction_test.go index d4cb2d4..8d2075b 100644 --- a/internal/app/tests/appaction_test.go +++ b/internal/app/tests/appaction_test.go @@ -59,6 +59,13 @@ app = ace.app("testApp",