diff --git a/admin/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js b/admin/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js new file mode 100644 index 00000000000..14b779bbda4 --- /dev/null +++ b/admin/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js @@ -0,0 +1,17 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + connect() { + this.element.addEventListener("submit", this) + } + + disconnect() { + this.element.removeEventListener("submit", this) + } + + handleEvent() { + for (const element of this.element.elements) { + element.setAttribute("readonly", true) + } + } +}