This topic is locked

Auto populate Field

8/21/2009 12:00:05 PM
PHPRunner General questions
M
mauro author

i have a table A
user

name

tel
and another table B
user

name

tel

note
when i add new data in table B, for field user i use a lookup wizard from table A, i'd like auto-populate other field of table B according to user selected.

I know that's possible using "category control" and "category Field" but for me is not a good choise (I'll have the same result on Edit Page) so

it's possible using events for example?

J
Jane 8/24/2009

Hi,
you can use Before record added event to fill these fields.

Here is a sample:

global $dal;

$rs = $dal->TableA->Query("user='".$values["user"]."'","");

$data = db_fetch_array($rs);

$values["name"] = $data["name"];

$values["tel"] = $data["tel"];
M
mauro author 8/24/2009

Ok

but i've this error

Undefined variable: data
on file_add.php :

--------------------------
{

$defvalues["tel"]=$data["tel"];

$defvalues["pc"]=$ip=$_SERVER['REMOTE_ADDR'];;

$defvalues["date1"]=now();

$defvalues["date2"]=now();

}

J
Jane 8/25/2009

Hi,
do not add $data["FieldName"] as default value on the "Edit as" settings dialog.

Just add whole code to the Before record added event.