Forums

Saving and using options labels??

junk4jake 03 Apr, 2014
I have a form where I am using a DROP DOWN with the classical value=label system because the third party system I send the information to doesn't care about the label, just the value as an account ID. On the otherhand, my website visitors only know them by the label and not the ID. On my "thank you" message and the "confirmation email" that I send them I want to reference the name of their selection but can't figure out how to save it to the database and also to reuse it in the HTML message and email.

the dropdown is built like this:

Field Name: provider
Field title: School Name
Multiple: (not checked)
Size: 1
Selected: (empty)
Show Empty: Please Select
Options:
123456=Jake University of Theology
234567=Anthony College
456454=Bart Simpson Homeschooling
564645=Homer's Beer Drinking Class
Field ID: provider
Field Class: (empty)

What I want to do is reference on the thank you page something like this:

Thank you {name} for choosing to enroll at {providername}!



However I can only get it to save the 6 digit number to the database and can't figure out how to reuse the same label. If I ask them to use the ID's, they won't know them and if the thank you message only uses the ID numbers, it will confuse them.
junk4jake 14 Apr, 2014
The link you sent me is definitely what I want to do, but I can't figure it out.

What I did was create on page 1 of my form the dropdown. It contains the value = text still.

field name: provider

options:
abcdef=Jake Jones University of Theology
123456=Home Schooling University
456789=Harvard Law
231587=Culinary Academy

I have also on page 1 created a CUSTOM CODE event that looks like this:

Action Label: provider_array

<?php
$provider_array = array(
abcdef => 'Jake Jones University of Theology',
123456 => 'Home Schooling University',
456789 => 'Harvard Law',
231587 => 'Culinary Academy'
);
$form->data['provider_name'] = $provider_array[$form->data['provider']];
?>



Should I be leaving the options blank and linking them together somehow?
junk4jake 14 Apr, 2014
BTW, I removed everything from the "Options" and enabled "Dynamic Data" and pointed the array field to "$form->provider_array" but then the drop down isn't populated with the options
Max_admin 16 Apr, 2014
So you want to use the dropdown labels in the email..etc ? then your code below should do it if its placed inside a custom code action before the email..etc:
<?php
$provider_array = array(
abcdef => 'Jake Jones University of Theology',
123456 => 'Home Schooling University',
456789 => 'Harvard Law',
231587 => 'Culinary Academy'
);
$form->data['provider_name'] = $provider_array[$form->data['provider']];
?>


You will have to use {provider_name}

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
junk4jake 16 Apr, 2014
I feel like a dumbass, now I can't see my options in the dropdown now, do I still need to have the simple array listed in the options field like this:

abcdef=Jake Jones University of Theology
123456=Home Schooling University
456789=Harvard Law
231587=Culinary Academy
junk4jake 16 Apr, 2014
I think I figured that out, I had to remove the "YES" portion for dynamic data I think.
This topic is locked and no more replies can be posted.