This topic is locked

swal with popup add page

1/26/2026 03:26:48
PHPRunner General questions
ffrinai author

phprunner 10.91 build 41974 x64

ADD PAGE
i have in js onloadevent
if (proxy["errorcf"]){
swal({
title: "Attenzione !!!",
text: proxy["errorcf"],
icon: "error",
button: "Ok"//,
});
}

in before record added
$cerca = "idanagpers = " . $values['idanagpers'] . " and idtipo_persona = ". $values['idtipo_persona'] ;
$rs = DB::Select("dettaglio_beneficiari", $cerca);
if ($record = $rs->fetchAssoc()) {
$message = "already present ->".$values['tipe_ruolo'];
$pageObject->setProxyValue("errorcf", $message);
return false;
}else{
return true;
}

and it works fine , the swal message is correct displayed, but if i recall the add page from parent list page, the add page is in popup and th swal is not displayed.

img alt
when i click save the message is displayed but not the swal. Is there a way to display the swal ?
thanls
Fabio

ChatGPT 1/26/2026

It seems like you're encountering an issue with displaying the SweetAlert (swal) popup when the "Add Page" is opened in a modal (popup) from the parent list page in PHPRunner. This is a common scenario when dealing with modals and JavaScript events.

Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Check for JavaScript Errors: Open the developer console in your browser (usually F12) and check for any JavaScript errors that may prevent the swal from being displayed.


  2. Ensure Proper Loading of SweetAlert: Make sure that the SweetAlert library is properly loaded when the modal is opened. Sometimes, if the script is not included in the context of the modal, it can lead to issues.


  3. Use onload Event for Modal: If the onload event is not firing for your modal, consider using a different event that is triggered when the modal is shown. For example, you could bind your swal code to a custom event that you trigger after the modal is displayed:

    $(document).on('shown.bs.modal', function () {
    if (proxy["errorcf"]) {
    swal({
    title: "Attenzione !!!",
    text: proxy["errorcf"],
    icon: "error",
    button: "Ok",
    });
    }
    });

  4. Check if the Modal is in the DOM: Ensure that the modal is part of the DOM when you are trying to show the swal popup. If the modal is dynamically created, the elements might not be ready when you attempt to show the alert.


  5. Modify the Add Page Configuration: In PHPRunner, check if there are any settings regarding JavaScript execution for the modal. Sometimes there are options that control how scripts are executed when a modal is opened.


  6. Using Custom JavaScript Events: If the above steps do not work, consider using a custom event to trigger the swal:

    // Trigger this event when setting the error message
    $(document).trigger('showErrorAlert', [proxy["errorcf"]]);

    // Listen for the event
    $(document).on('showErrorAlert', function (event, errorMessage) {
    if (errorMessage) {
    swal({
    title: "Attenzione !!!",
    text: errorMessage,
    icon: "error",
    button: "Ok",
    });
    }
    });


By implementing one or more of these suggestions, you should be able to get the SweetAlert popup to display correctly even when the "Add Page" is opened as a modal. If you continue to have issues, please provide more details about your setup or any error messages you encounter.