Skip to content

Commit

Permalink
Showed error in accordion items
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Dec 15, 2024
1 parent 580d305 commit 8af2144
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions assets/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,20 @@ window.addEventListener("load", () => {
}
}
});

// Open accordions with errors on submit.
document.addEventListener("ea.form.error", (event) => {
const { page, form } = event.detail;
// alert(`The ${page} form contains errors. Please resolve these before submitting again.`)
const elements = form.querySelectorAll(".accordion-item .has-error");
for (const el of elements) {
const item = el.closest(".accordion-item");
const button = item?.querySelector(".accordion-header button");
const contents = item?.querySelector(".accordion-collapse");
if (button && contents) {
button.classList.remove("collapsed");
contents.classList.add("show");
}
}
});
});

0 comments on commit 8af2144

Please sign in to comment.