This topic is locked

assign values in Add page: Before display event

2/9/2009 11:39:01 AM
PHPRunner General questions
L
laonian author

I want to conditionally assign some values in the Add page: Before display event. I have used this in the 4.2 version and it worked great.
A working sample code in v4.2:
if (date("d")<10)

$smarty->assign("value_Total", 100.00);

else

$smarty->assign("value_Total", 125.00);
When I opened the project in v5.0 (tried a few builds including the latest 766), the code is change to this ($smarty replaced with $xt):
if (date("d")<10)

$xt->assign("value_Total", 100.00);

else

$xt->assign("value_Total", 125.00);
When I ran the application, it gave an error message: Undefined variable xt. I then added "global $xt;" at the beginning of the event page. Now when I ran the application again, I got no error message, but the code doesn't do anything. I also tried to modify the code to:
$xt->assign("Total_value", 100.00);

or

$xt->assign("Total", 100.00);
but nothing works. I am not sure what I did wrong with it. Please help. Thanks.

J
Jane 2/12/2009

Hi,
try to use this code:

global $control_FieldName;

$control_FieldName["params"]["value"]=100;