Only return HTTP 422 while validating the invoice’s form if not HTMx
This commit is contained in:
parent
754da87e45
commit
835bab357e
|
@ -463,7 +463,9 @@ func HandleAddInvoice(w http.ResponseWriter, r *http.Request, _ httprouter.Param
|
|||
return
|
||||
}
|
||||
if !form.Validate() {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
if !IsHTMxRequest(r) {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
}
|
||||
mustRenderNewInvoiceForm(w, r, form)
|
||||
return
|
||||
}
|
||||
|
@ -840,7 +842,9 @@ func HandleUpdateInvoice(w http.ResponseWriter, r *http.Request, params httprout
|
|||
} else {
|
||||
slug := params[0].Value
|
||||
if !form.Validate() {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
if !IsHTMxRequest(r) {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
}
|
||||
mustRenderEditInvoiceForm(w, r, slug, form)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue