How to perform a fake true insert? (v2020)

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
gigakun
User
Posts: 99

How to perform a fake true insert? (v2020)

Post by gigakun »

Good Day all. Here's what I'm trying to do. I have a master/detail window. I click the icon to open a modal insert window for the detail table. I have single 1 visible field here (add page), which is a custom field dropdown. It's purpose is simply for the user to decide what action to do next, go to this page, go to that page. I have the redirect depending on what action is performed. My redirect works by setting a session variable in the row inserting event for the detail table based on the action selected in the drop down. After the insert is down the modal closes and the master detail view refreshes and uses the session varibale to detect which page to go to.

The problem is PHPMaker still attempts to insert an empty row into the database. While it's not major the issue is that the autoincrement counter keeps increasing unecessarily. And when I'm ready to an actual insert the ID's will come out like 2,4,6,8 etc. or potientially even worse

I've tried returning false, But that throws up the failure message and my redirect fails because the modal doesn't close.
I've tried returning false and clearing the failure message but the modal won't close.
I've tried returning true and clearing the rsnew array with unset($rsnew) but an empty row is physically inserted
I've tried returning true and clearing the rsnew array with $rsnew = "" an empty row is attempted to be inserted but doesn't actually and PK is incremented

How can I return a true insert but actually stop PHPMaker from attempting to do the insert? If that makes any sense lol


mobhar
User
Posts: 11702

Post by mobhar »

You need to clear your session variable(s) after the inserting process are done, so that the next insert will not use that previous session variable(s).


arbei
User
Posts: 9355

Post by arbei »

If you don't need to insert a record, you don't need to make a modal Add page at all. If you just want to create a modal dialog for user to choose something, just use sweetalert, see Input Types -> select.

If you must use the Add form, you need to return JSON result to simulate success, check HTTP Response and return your JSON result similarly.


gigakun
User
Posts: 99

Post by gigakun »

Thanks. That gave me an idea this v2020 so I don't have sweetalert. So I used regular javascript to redirect the page once a option is selected from drop down. Thanks


Post Reply