How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)

This following code will show you how to display the View/Edit page in modal dialog that belongs to another tables by using PHPMaker v2021. Actually, this trick is working also in v2020, but this time I obviously chose v2021, since I used the specific link to open the page in Modal dialog that only working in v2021 (which supports URL rewrite). If you want to implement this for v2020, then you need to adjust the url param from code below.For simplicity, we need to use demo project that you may download and try by yourself for PHPMaker v2021: https://phpmaker.dev/demo2021.zipSo, we want to display Modal dialog to open View page of orders table for OrderID field from orders2 List page… and also open Edit page of customers table in Modal dialog for CustomerID field in orders2 List page.


  • Just copy this following code in Row_Rendered server event that belongs to orders2 table:
    if (CurrentPageID() == "list" || CurrentPageID() == "view") {
    	$this->OrderID->ViewValue = "<a href='#' onclick='ew.modalDialogShow({lnk:this,url: \"orders/view/".$this->OrderID->CurrentValue."\",btn: \"ViewBtn\"});'>" . $this->OrderID->ViewValue . "</a>";
    	$this->CustomerID->ViewValue = "<a href='#' onclick='ew.modalDialogShow({lnk:this,url: \"customers/edit/".$this->CustomerID->CurrentValue."\",btn: \"EditBtn\"});'>" . $this->CustomerID->ViewValue . "</a>";
    }
  • Don’t forget to re-generate ALL the script files, as usual. :wink:
  • Now login using username/password: admin/master from the generated web application, then go to orders2 List page. As you can see, when you click on link in OrderID from orders2 List page, it will open View page of orders table in Modal dialog
  • The similar thing also for CustomerID; will open Edit page of customers table in Modal dialog from orders2 List page.

As always, happy coding, everyone! :slight_smile:

1 Like

It should not work in v 2018 or I’m doing something wrong?

This code is only for v2021. I am afraid that it does not work for v2018.

sorry, table is missing userlevel and userlevelpermisions

Does this code work for v2023?

Yes, it should work also for v2023 after doing some modification for the code.This code:
$this->OrderID->ViewValue = “” . $this->OrderID->ViewValue . “”;should be:
$this->OrderID->ViewValue = “” . $this->OrderID->ViewValue . “”;In other words, this code:
btn: "ViewBtn"should be:
btn: nullThe other code remains the same.

After testing it, it works, but when using Editbtn after editing the data. Content on that page will disappear.

What did you mean by Content on that page will disappear? Did you mean the Modal dialog is closed and back to the List Page of orders2 table?

When you press confirm The page where the button was created turned white with a message that edited successfully. This button is created on the viewing page.

Did you enable Confirm option for Edit Page of customers table? In addition, did you setup Return Page after edit?

in edit page for custom link use confirm. but not set return page.

I cannot reproduce the issue.

I’ve just tried to enable Confirm option for Edit Page of customers table and then re-generate ALL the script files again.

In the generated web application, everything seems fine, after clicking on Save button, then system will display the Confirm button immediately, and after clicking one Confirm button, then data is saved properly, and Modal dialog is closed as usual.