How to open a page in a modal dialog after Row_Inserted event?

Hi everyone,

I’m using PHPMaker (version 2025). In my Row_Inserted event, I want to open another page in a modal dialog immediately after inserting a record. This is my current code:

public function Row_Inserted(?array $oldRow, array $newRow): void
{
    if ($newRow["oggetto"] == 118) {
        // URL of the page to open
        $url = "tblraprischioadd?showmaster=tbl_rap_generale&fk_id_rapporti=" . urlencode($newRow["id_rapporti"]);

        // Redirect to the page
        $this->terminate($url);
    }
}

Right now, $this->terminate($url); just opens the page normally (a full redirect), but I need it to open in a modal dialog. In older versions, using something like

$this->terminate("javascript:ew.modalDialogShow(...);");

used to work, but in the newer versions, it no longer executes the JavaScript.

Question:
How can I modify my code so that, after the record is inserted, PHPMaker will open tblraprischioadd inside a modal dialog instead of doing a full page redirect?

Thank you!

It depends how you add your record. If you use normal Add page (by HTTP POST), you cannot output JavaScript like your example. If you use modal Add page, you may output JSON, e.g.

WriteJson(["url" => $url]);
$this->terminate();

This might help: Redirect to Another Page in Modal Dialog after Inserting a New Record in Modal Dialog (v2025)