This commit is contained in:
Ziver Koc 2023-01-06 18:04:37 +01:00
parent bbd03b14be
commit 30cfcc7816

View file

@ -28,22 +28,22 @@
if (formTemplateId != null) if (formTemplateId != null)
modal.find("#" + formTemplateId).empty(); // clear form div modal.find("#" + formTemplateId).empty(); // clear form div
// set dynamic form data // Set dynamic form data
$.each(button.attr(), function(fieldName, value) { $.each(button.attr(), function(fieldName, value) {
if(fieldName.startsWith("data-")) { if(fieldName.startsWith("data-")) {
fieldName = fieldName.substring(5); // remove prefix data- fieldName = fieldName.substring(5); // remove prefix data-
// case insensitive search // Case-insensitive search
var input = modal.find("input, select").filter(function() { var input = modal.find("input, select").filter(function() {
if (this.name.toLowerCase() == fieldName) { if (this.name.toLowerCase() == fieldName) {
if (this.type == "hidden" && modal.find("input[type=checkbox][name=" + fieldName + "]") != null) if (this.type == "hidden" && modal.find("input[type=checkbox][name=" + fieldName + "]").length > 0)
return false; // Workaround for the default(false) boolean input return false; // Workaround for the default(false) boolean input
return true; return true;
} }
return false; return false;
}); });
if (input != null) { if (input.length > 0) {
if (input.prop("type") == "checkbox") { // special handling for checkboxes if (input.prop("type") == "checkbox") { // special handling for checkboxes
input.prop("value", "true"); input.prop("value", "true");
input.prop("checked", value == "true"); input.prop("checked", value == "true");