mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Fixed modal send more forms
This commit is contained in:
parent
14e4e37c2a
commit
f34387b24e
@ -2058,6 +2058,25 @@ function load_modal(settings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
settings.form.forEach(function(element) {
|
||||||
|
$("#" + element + " :input").each(function() {
|
||||||
|
// TODO VALIDATE ALL INPUTS.
|
||||||
|
if (this.type == "file") {
|
||||||
|
if ($(this).prop("files")[0]) {
|
||||||
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($(this).attr("type") == "checkbox") {
|
||||||
|
if (this.checked) {
|
||||||
|
formdata.append(this.name, "on");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flagError === false) {
|
if (flagError === false) {
|
||||||
@ -2088,7 +2107,7 @@ function load_modal(settings) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
// console.log(data);
|
console.log(data);
|
||||||
AJAX_RUNNING = 0;
|
AJAX_RUNNING = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2111,101 +2130,8 @@ function load_modal(settings) {
|
|||||||
modal: true,
|
modal: true,
|
||||||
title: settings.modal.title,
|
title: settings.modal.title,
|
||||||
width: width,
|
width: width,
|
||||||
overlay: {
|
overlay: settings.modal.overlay,
|
||||||
opacity: 0.5,
|
buttons: required_buttons,
|
||||||
background: "black"
|
|
||||||
},
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
class:
|
|
||||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
|
|
||||||
text: settings.modal.cancel,
|
|
||||||
click: function() {
|
|
||||||
$(this).dialog("close");
|
|
||||||
if (typeof settings.cleanup == "function") {
|
|
||||||
settings.cleanup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
class:
|
|
||||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
|
||||||
text: settings.modal.ok,
|
|
||||||
click: function() {
|
|
||||||
if (AJAX_RUNNING) return;
|
|
||||||
AJAX_RUNNING = 1;
|
|
||||||
if (settings.onsubmit.preaction != undefined) {
|
|
||||||
settings.onsubmit.preaction();
|
|
||||||
}
|
|
||||||
var formdata = new FormData();
|
|
||||||
if (settings.extradata) {
|
|
||||||
settings.extradata.forEach(function(item) {
|
|
||||||
if (item.value != undefined) {
|
|
||||||
if (
|
|
||||||
item.value instanceof Object ||
|
|
||||||
item.value instanceof Array
|
|
||||||
) {
|
|
||||||
formdata.append(item.name, JSON.stringify(item.value));
|
|
||||||
} else {
|
|
||||||
formdata.append(item.name, item.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
formdata.append("page", settings.onsubmit.page);
|
|
||||||
formdata.append("method", settings.onsubmit.method);
|
|
||||||
if (Array.isArray(settings.form) === false) {
|
|
||||||
$("#" + settings.form + " :input").each(function() {
|
|
||||||
if (this.type == "file") {
|
|
||||||
if ($(this).prop("files")[0]) {
|
|
||||||
formdata.append(this.name, $(this).prop("files")[0]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($(this).attr("type") == "checkbox") {
|
|
||||||
if (this.checked) {
|
|
||||||
formdata.append(this.name, "on");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
formdata.append(this.name, $(this).val());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
settings.form.forEach(function(element) {
|
|
||||||
$("#" + element + " :input").each(function() {
|
|
||||||
if (this.type == "file") {
|
|
||||||
if ($(this).prop("files")[0]) {
|
|
||||||
formdata.append(this.name, $(this).prop("files")[0]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($(this).attr("type") == "checkbox") {
|
|
||||||
if (this.checked) {
|
|
||||||
formdata.append(this.name, "on");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
formdata.append(this.name, $(this).val());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
method: "post",
|
|
||||||
url: settings.url,
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
data: formdata,
|
|
||||||
success: function(data) {
|
|
||||||
if (settings.ajax_callback != undefined) {
|
|
||||||
settings.ajax_callback(data);
|
|
||||||
}
|
|
||||||
AJAX_RUNNING = 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
closeOnEscape: false,
|
closeOnEscape: false,
|
||||||
open: function() {
|
open: function() {
|
||||||
$(".ui-dialog-titlebar-close").hide();
|
$(".ui-dialog-titlebar-close").hide();
|
||||||
@ -2223,7 +2149,13 @@ function load_modal(settings) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Function that shows a dialog box to confirm closures of generic manners. The modal id is random
|
/**
|
||||||
|
* Function that shows a dialog box to confirm closures of generic manners.
|
||||||
|
* The modal id is random
|
||||||
|
*
|
||||||
|
* @param {array} settings Settings.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
function confirmDialog(settings) {
|
function confirmDialog(settings) {
|
||||||
var randomStr = uniqId();
|
var randomStr = uniqId();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user