diff --git a/assets/app.js b/assets/app.js index 6ced00b..36c5a9f 100644 --- a/assets/app.js +++ b/assets/app.js @@ -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 + } +})