Tip: setting the initial value of field by code

Hi,

I had a problem with setting the value of a field in the OnApplicationInit and OnScriptInit.

The following didn’t work


if(isset($_SESSION['GSM']))
{
     {phonenumber} = $_SESSION['GSM'];
}	

Where the session came from a parent dialog.

So, the tip is as follows. Add the following in the defined value of a field (settings).


". $_SESSION['GSM'] . "

However, a even better way is to wrap this into a method (function) so just as an example:


". $this->setgsmnumber() . "

Cheers,
Sparrow

Most easy way is:


if(isset($_GET['GSM']))
{
     {phonenumber} = $_GET['GSM'];
}

Yes Albert,

but that didn’t work for some reason. Still don’t know why but the value didn’t get set.

Cheers
Sparrow

Hi Sparrow, you sample is about $_SESSION which means that the data passed by the url is not seen, it needs to be in the session first. So in your case not the right design.$GET does get the data from the url and works, but it depends on how you call the application. $_GET or $_POST

Hi Albert,

hm… ok I understand your point but can you explain why the $_SESSION[‘GSM’] does work in the function setgsmnumber ?

[QUOTE=sparrow;31252]Hi Albert,

hm… ok I understand your point but can you explain why the $_SESSION[‘GSM’] does work in the function setgsmnumber ?[/QUOTE]

No. It’s virtually impossible to know without looking at the code. You know, I try to help with the php standards I know and I have struggled with $_SESSION first to find out that I needed to use $_POST and $_GET. That’s what I share.

Hi Albert,

No problem. I thank you for your contribution !