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
|
return
|
||||||
}
|
}
|
||||||
if !form.Validate() {
|
if !form.Validate() {
|
||||||
|
if !IsHTMxRequest(r) {
|
||||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||||
|
}
|
||||||
mustRenderNewInvoiceForm(w, r, form)
|
mustRenderNewInvoiceForm(w, r, form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -840,7 +842,9 @@ func HandleUpdateInvoice(w http.ResponseWriter, r *http.Request, params httprout
|
||||||
} else {
|
} else {
|
||||||
slug := params[0].Value
|
slug := params[0].Value
|
||||||
if !form.Validate() {
|
if !form.Validate() {
|
||||||
|
if !IsHTMxRequest(r) {
|
||||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||||
|
}
|
||||||
mustRenderEditInvoiceForm(w, r, slug, form)
|
mustRenderEditInvoiceForm(w, r, slug, form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue