How do I put a dropdown label (not value) in an email?

jj135 10 Jul, 2017
Hi!

I have a dropdown like this:

1=name1
2=name2

When I put {data:dropdown} in the e-mail body (no auto generation) it show the chosen value. (1 or 2) But I would like to display the label in the email. How can I achieve this?

When I set the 'Auto add fileds data' to 'on' is automatically displays the label instead of the value. So I guess this can be done somehow.

Kind regards,
JIp
jj135 10 Jul, 2017
Hi Bob!

I can not find a 'handle arrays' action in CF6. So that option won't work I guess.

I also can not change the values of the dropdown. I use te dropdown to let a user select a usergroup. The value needs to be an integer, but the label needs to be the usergroup name. So I can not use that option to get the label in e-mail.

he dropdown options are in my case:

11={l:RF_VERKOPER}
13={l:RF_KOPER}

I use the form localisation to display these values in 4 different languages.

I think I could try to add the PHP code. Will that work in CF6?

It would be nice to be able to use a 'tag' to get the label of a value. Maybe something like:

{data.label:type_account}

Just a thought... This would make things a bit easier I think.

But I'll just try PHP for now. Hope that works...
jj135 10 Jul, 2017
Hi! The PHP is a bit different for CF6. I managed to gt what I need with this PHP code:

$usergroupId = $this->data("type_account");
$usergroupName = "not set";
if ($usergroupId == 11) { $usergroupName = "Verkoper"; }
if ($usergroupId == 13) { $usergroupName = "Koper"; }
return $usergroupName;

Just wondering: Would it be possible (not meed for me right now) to use a language string is this PHP code?

Something like:

if ($usergroupId == 11) { $usergroupName = "{l:thegroupname}"; }

And as I said before: A simpler solution would be to be able to use a tag tot get the 'related' option label. ;-) Like:

{data.label:type_account} or {data.type_account.label} or something similar...

Kind regards,
Jip
Max_admin 15 Jul, 2017
Hi Jip,

This is done using a "Switch" action, please check my reply here:
http://www.chronoengine.com/forums/posts/t103957/save-user-assign-group-according-to-switch.html

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.