using label

7 posts by 3 authors in: Forums > CMS Builder
Last Post: August 12, 2011   (RSS)

Re: [Toledoh] using label

By Dave - August 10, 2011

Tim,

We'd have to pull it out of the database somehow. Are you loading any records on the same page? And where is the project num/name stored? In another table or in a list of values in the field editor?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] using label

By Toledoh - August 11, 2011

Hi Dave.

I've got the following in a form;

<?php $fieldname = 'project'; ?>
<?php $idCounter = 0;
$selectedProjects = explode("\t", trim($CURRENT_USER['project'], "\t"));
?>

<?php foreach (getListOptions('accounts', $fieldname) as $value => $label): ?>
<?php if (!in_array($value, $selectedProjects)) { continue; } ?>
<?php $idP = "$fieldname." . ++$idCounter; ?>
<input type="radio" name="<?php echo $fieldname ?>" id="<?php echo $idP ?>"
value="<?php echo htmlspecialchars($value) ?>" <?php checkedIf(@$_REQUEST[$fieldname], $value) ?> />
<label for="<?php echo $idP ?>"><?php echo htmlspecialchars($label) ?></label><br/>
<?php endforeach ?>


when the form is updated an email is generated, and I want to identify in the email, what project (and other data) has been selected...
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] using label

By Jason - August 11, 2011

Hi Tim,

You can use getListOptions() to get an array of all of the value/label combinations and then use the $_REQUEST['project'] value to get the label you want. For example:

<?php
$listOptions = getListOptions('accounts', 'project');

$emailProject = "";

if (@$_REQUEST['project']) {
$emailProject = $listOptions[@$_REQUEST['project']];
}

?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] using label

By Toledoh - August 11, 2011

Hi Jason.

That's still returning the value, not the label.

"project" is a list with value=num and label=title.

So when I use this $_REQUEST['project'] I get the "num" but I want to display the "title"...
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] using label

By Jason - August 12, 2011

Hi Tim,

Instead of referencing $_REQUEST['project'] directly, you should be able to get the label by using the code above and referencing:
$listOptions[@$_REQUEST['project']];

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] using label

By Toledoh - August 12, 2011

Hi Jason.

My mistake, I still had "$emailProject = @$_REQUEST['project'];" later in the code, left over from me trying to get it to work.

You'r version works great! Thanks
Cheers,

Tim (toledoh.com.au)