Clear the master key value in the detail add page

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

Clear the master key value in the detail add page

Post by Creabis »

I have a problem with a master/detail setup. When I open a master/detail page the master field value is remembered when I open the standalone detail add page.
An example:
Order > Orderdetails is an master/detail setup. When once I open order 1234 the script remembers this value. When visiting the addpage orderdetailsadd.php directly the script fills in automatically 1234 in the orderfield because it sees that it has an master/detail relationship. Normally this is good. But I want to clear the master value.

Is it possible to clear this master key value in the add page when you just visited a master record. So the order field in the details add page will be blank?


mobhar
User
Posts: 11718

Post by mobhar »

Creabis wrote:
Is it possible to clear this master key value in the add page when you just visited
a master record

Did you mean you want to clear the master key value in the Add page when you just visited the detail record (not a master record)?


arbei
User
Posts: 9381

Post by arbei »

You can reset the foreign key in the Page_Load Server Event as below.

$this-><FK field->setSessionValue("");


kirondedshem
User
Posts: 642

Post by kirondedshem »

What I usually do to avoid the headaches is to separate concerns by create a separate editable view for each table I have as a detail somewhere and as a standalone list page somewhere.

For example If the detial table is called table_detail.
I can setup a standalone list page from the actual table.
Then If I have to use the same table in a master detail relationship, I create an editable view like.
CREATE VIEW vw_dt_table_detail as select * from table_detail;
I copy field settings and I then attach this to any master tables I want.
This format gives me the following advantages:
-That way the two will never interfere with each other coz of master/detail setup
-since this is an editable view, the view can still be used for adding and editing, so it can still do everything the original table does.
-I can easily customize each minus interfering with the other. ie when you are in a scenario where you want to customize how the add/edit mage of a master/detail relationship should look like in comparison to a standalone add/edit, it becomes difficult if you have to maintain both customizations on the same table.


Creabis
User
Posts: 22

Post by Creabis »

That is exactly what I did, thanks to PHPmaker it is easy to setup an editable view of the table.

But I was wondering if there was a 'proper' way to do this. I will try it with Arbei's solution.

Thanks for your thoughts.


mobhar
User
Posts: 11718

Post by mobhar »

Since the foreign key is saved into a session, then arbei's solution above is a proper way to do this.


Post Reply