This topic is locked

Automatically add first detail record

10/15/2009 1:21:39 AM
PHPRunner General questions
E
electromotive author

Hi. Maybe some kind person can help me.
I have a common master-slave relationship. Imagine it like a purchase order. It only makes sense when there is at least one detail record.
So when I add the master record, next I need it to automatically go to the (first) add_detail form, without having the user click the buttons to navigate to get there; ie., going first to the list and then do the add. After the detail_add the user can go back to the detail_list, and add more if necessary as normal. This must be a common requirement, but searching the the forums and manual I see no examples of how to do this 2 step.

J
Jane 10/15/2009

Hi,
use After record added event on the Events tab for this purpose.

Here is a sample code:

$_SESSION["DetailTableName_mastertable"] = "MasterTableName";

$_SESSION["DetailTableName_masterkey1"] = $keys["FieldName"];

header("Location: DetailTableName_add.php");

exit();



where FieldName is your actual field name where master key is stored, DetailTableName and MasterTableName are your actual table names.

E
electromotive author 10/15/2009
D
danaci 10/16/2009

detail table comes with blank fields

J
Jane 10/16/2009

Hi,
please make sure $_SESSION["DetailTableName_mastertable"]and $_SESSION["DetailTableName_masterkey1"] are filled correctly in your event.