send number of files

This commit is contained in:
Zhora Shalyapin 2024-12-28 15:48:15 +00:00
parent 26f492b8f0
commit 49dc41ea41

View File

@ -364,6 +364,7 @@
form.removeChild(was)
form.appendChild(became)
setInputValues(became, inputValues)
createSendButtons()
}
function prettify(form, was, became, insertedFileRows) {
@ -456,6 +457,8 @@
}
function createSendButtons() {
if (document.querySelector("button.safe-action")) return
let saveButtons = [...document.querySelectorAll("input[name=\"save_go\"]"), ...document.querySelectorAll("input[name=\"save_exit\"]")]
for (let saveButton of saveButtons) {
@ -465,6 +468,12 @@
pseudoSaveButton.classList.add("safe-action")
pseudoSaveButton.addEventListener("click", async () => {
let formData = new FormData(document.querySelector("form"))
let fileContainers = [...document.querySelectorAll(".file-list-container")]
let fileInputNames = ["legend_photo", "legend_files", "admin_photo", "admin_files"]
for (let [i, fileContainer] of fileContainers.entries()) {
formData.set(`cp[${fileInputNames[i]}]`, fileContainer.children.length)
}
let props = document.querySelectorAll("input[name^=\"prop_\"]");
for (let prop of props) {