diff --git a/src/components/Form.astro b/src/components/Form.astro index 6c7e25e..3658438 100644 --- a/src/components/Form.astro +++ b/src/components/Form.astro @@ -412,6 +412,16 @@ const formId = `f-${Math.random().toString(36).slice(2)}`; t.value = t.getAttribute("data-initial") || ""; t.removeAttribute("data-initial"); }); + + form.addEventListener("wr:set-errors", (e) => { + const map = e.detail || {}; + Object.entries(map).forEach(([name, message]) => { + const root = form.querySelector( + `[data-field="${CSS.escape(name)}"]`, + ); + if (root) setError(root, message || "Invalid value"); + }); + }); }; if (document.readyState === "loading") {