This topic is locked

Default value and foreign key

2/21/2006 09:06:04
PHPRunner General questions
Z
zavka author

Hi
I have Master and Detail table. Phprunner (3.0 build 86) always puts this -> @$_SESSION[$strTableName."_masterkey"]

as default value for field that is foreign key in Detail table.

Can I set my own default value for this field???

Sergey Kornilov admin 2/21/2006

Hi,
To set your own default value check off Add for this field on the Choose fields Tab and set your default value on the Formatting Tab.

However if you set your own default value you have to manually tie child records to master table record putting correct value to this field on the ADD page.

Z
zavka author 2/22/2006

Maybe possible is catch default values in AddOnLoad() and put some code there???
Events are great idea in PhpRunner 3.0!!!

Sergey Kornilov admin 2/22/2006

Hi,
yes, you can calculate default values in OnLoad event.

Then use session variables to pass these values to controls.
I.e. set the default values for your field:

$_SESSION["Field1"]


Then put the code to AddOnLoad event, that will calculate the default value and put it to

$_SESSION["Field1"].

Z
zavka author 2/22/2006

OK, but what if I want this scenerio:
Step 1

Go Master Table

Go Detail Table

Default value for field-foreign key is: @$_SESSION[$strTableName."_masterkey"]
Step 2

Go Detail Table

Default value field-foreign key is: "2006-"
Any idea?

How make this to work?

Sergey Kornilov admin 2/24/2006

Hi,
please set

@$_SESSION[$strTableName."_masterkey"]?@$_SESSION[$strTableName."_masterkey"]:"2006-"

as default value for field-foreign key.

Don't forget add this field to the ADD page.

Z
zavka author 2/24/2006

It works great!

Thanks a lot!!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=8173&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />