Pulldown Fields - Value vs. Label

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 21, 2008   (RSS)

Re: [InHouse] Pulldown Fields - Value vs. Lable

By Dave - August 20, 2008

Hi J,

There's no elegant built in way to do this yet. I think in future we may add pseudo fields that let you refer to either value as: fieldname:label or fieldname:value.

It is stored in the database as a value, and a label is shown in many cases on the backend as that's usually when people want (except when they don't!). :)

Anyways, here's some code to get the label from the value.

<?php
$tableName = 'news';
$fieldName = 'related';
$fieldValue = $newsRecord['related'];
$labelArray = getListLabels($tableName, $fieldName, "\t$fieldValue\t");
$label = @$labelArray[0];
?>

Just replace the variable name with your own and then use $label where you want the label to appear.

Let me know if this works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Pulldown Fields - Value vs. Lable

By InHouse - August 21, 2008

Thanks Dave! At least I'm not missing something obvious here (for a change).

I'll take your suggestions on board and see what I can make work.

Thanks for your input as ever.

Cheers,
J.