In PHPMaker 2024, I’ve added the following code to “Client Scripts → Table Specific → Add Option Page → Client Script”
$(document).ready(function() {
// Add the button next to the JacketID field dynamically
$('#x_JacketID').parent().append(
'<button type="button" class="btn btn-default ew-add-opt-btn" id="btnNestedModal" title="Add Jacket">Add Jacket</button>'
);
// Handle the button click event to open the nested modal
$('#btnNestedModal').on('click', function() {
ew.modalDialogShow({
url: "<?= GetUrl('TblJacketAddopt') ?>", // URL of the page to load in nested modal
caption: "Add Jacket" // Title for the nested modal
});
});
// Manage z-index for stacked modals
$(document).on('show.bs.modal', '.modal', function () {
var zIndex = 1050 + (5 * $('.modal:visible').length);
$(this).css('z-index', zIndex);
setTimeout(function () {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
});
// Restore z-index of previous modal when top modal is closed
$(document).on('hidden.bs.modal', '.modal', function () {
if ($('.modal:visible').length > 0) {
$(document.body).addClass('modal-open');
}
});
});
I receive a POST 401 error when I try to save the new row from the resulting stacked modal. Unable to authenticate. I don’t know how to add the proper authentication to the script to allow for the stacked (nested) modal to POST