Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Translating Values

Quote Reply
Translating Values

I have setup several relationships with small, secondary tables from my main table. And they all work as expected, except when it comes to showing search results.


I have a secondary table called 'Counties' with two colums 'IDNumber' and 'County_Name'. The IDNumber is the key. It is related to a column on my main table called 'County'.

When adding a record, a pull down list exists showing the user-friendly 'County_Names' to the user to select from. But when the results are shown from a search, they see the 'IDNUmber' instead. And while I know that '17' means Miami County, they don't. Wink

How can I translate the stored IDNumber field to show the "County_Names' field on search results?

Quote Reply
Re: [VanGogh] Translating Values In reply to
You need a global template to pull out County_Name from Counties table. Here is the code:

sub {
my $id = shift;
my $name = $DB->table('Counties')->select('County_Name', { IDNumber => $id })->fetchrow;
return $name;

Now you can use <%global_name($IDNumber)%> in the template


Quote Reply
Re: [TheStone] Translating Values In reply to
Worked great! Thanks!