fix: accept response code 422 in htmx as 'should swap'
This commit is contained in:
@@ -13,3 +13,12 @@ htmx.config.allowScriptTags = false
|
||||
htmx.config.withCredentials = true
|
||||
htmx.config.selfRequestsOnly = false
|
||||
htmx.config.timeout = 50000 // 50 seconds - slightly higher than backend timeout (45s)
|
||||
|
||||
document.body.addEventListener('htmx:beforeSwap', (event) => {
|
||||
// Symfony renders invalid forms with 422; let HTMX swap those responses so inline
|
||||
// validation errors are actually shown to the user.
|
||||
if (event.detail?.xhr?.status === 422) {
|
||||
event.detail.shouldSwap = true
|
||||
event.detail.isError = false
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user