Form Custom Form Error

This commit is contained in:
2025-08-17 20:43:33 +05:30
parent 0f1db96d49
commit aa92ac4144
+10
View File
@@ -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") {