This topic is locked

Autopopulate Lookup Tables

10/7/2005 10:51:46 AM
PHPRunner General questions
pplaut author

Hi,

I have a little glitch.

I have a master table with a required field.......... "status" Which is linked to a lookup table.
Since the field is required, the app dies if the field is not populated.

But, what makes it worse is the users don't take the time to populate these fields before starting the app. Even though the instructions say to.
What I want to know is this. Is there a way to set a couple of default values in the lookup table when the user registers, or uses the account for the first time....
Or, when using the lookup wizard, have some default values.
For this lookup table, each user has a uniqe set of data.
Thanks

Peer

Sergey Kornilov admin 10/10/2005

Peer,
to set default value for lookup field do the following:

  • build the project with required lookup field
  • open ..._function.php file by any text editor.

    Find GetDefaultValue($field)function.
  • change it this way:
    if($field=="FieldName") return "YourValue";

pplaut author 8/4/2006

Hey,

Been awhile, I am just now getting back to this.

With the new template options, can I do this with a template?

My understanding if I use the template, each time I generate new code, these will included.

Is this correct?

This product is getting better every day! I love you guys! You ROCK!
Here is what it looks like in the template I am using.

// returns field's default value

function GetDefaultValue($field)

{

global $strTableName;

ALLFIELDS## if($field=="##FIELD##") return ##DEFAULTVALUE##;

##/ALLFIELDS##

return $_SESSION[$strTableName."_fieldinfo"][$field]["default"];

}

If I have multiple fields do you create one for each line?

If you have muliple tables how do you handle that?

What would happen if you had two field names the same in two or more differnt tables? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=10211&image=1&table=forumreplies' class='bbc_emoticon' alt=':o' />
Table name = mos_addressbook_url_type Field Name = URL_Type

Table name = mos_addressbook_contact_type Field Name = contact_type
Peer

Alexey admin 8/7/2006

Peer,
the latest PHPRunner does support default values for lookup wizards.

So you don't need to edit anything manually.

Just use Default value box on Lookup wizard dialog on Formatting tab in PHPRunner.