Buy Now
Sign in

Load both value and label (or second selected field) to array

jformicola , May 26 2021, 19:55
J
jformicola 47
May 26 2021, 19:55 #396563
How do I go about loading both the value/key and a second field to the data array?
I have a dropdown that is being populated by a database read [read_data3] that is pulling two fields. When the person selects the option they want, only one field [EMPId] is making it to the array. I need "FullName" to make it too as I want to output the name on an email that is sent out after the form runs. I will still need the key to be EMPid as it is used is some custom sql/php that outputs a table onto the email. Does that make sense?
Thank you for any help!
Array
(
[read_data3] => Array
(
[log] => Array
(
[0] => SELECT `Data3`.`EMPId` AS `Data3.EMPId`, `Data3`.`FullName` AS `Data3.FullName` FROM `tblemployee` AS `Data3` ORDER BY `Data3.FullName` ASC LIMIT 1000;
)

[var] => Array
(
[1] => Abels, Julie
[1090] => Abreu, Maria
[79] => Abril, Manuel A.
I need another item here that displays the "FullName" then I should be able to output it on the email that is triggered after the form.
Array
(
[option] => com_chronoforms6
[cont] => manager
[chronoform] => trigger-summary
[event] => submit
[employee] => 228
[button6] =>
)
GreyHead 65
May 27 2021, 09:09 #396565
Hi jformicola,
I suggest that you use a Read Data action on Submit to get all the info you need using the submitted Employee ID.
Bob
If you'd like to buy me a coffee or two, thank you very much
J
jformicola 47
May 27 2021, 13:23 #396569
Thanks Bob! I did that but I can't seem to now output the result on the email. Can you please look at the below debug data and tell me what variable shortcode I can use to add Jason's name to my email?
Array
(
[chronoform] => trigger-summary
[event] => submit
[employee] => 228
[button6] =>
[Itemid] => 298
[option] => com_chronoforms6
[view] => form
)
Array
(
[submit_validate_fields] => Array
(
[log] => Automatic validation enabled.
[var] => 1
)

[read_data19] => Array
(
[log] => Array
(
[0] => SELECT `Data19`.`FullName` AS `Data19.FullName` FROM `tblemployee` AS `Data19` WHERE `Data19`.`EMPId` = '228' LIMIT 100;
)

[var] => Array
(
[Eifert, Jason R.] => Eifert, Jason R.
GreyHead 65
May 28 2021, 10:56 #396575
Hi jformicola,
I looked at healyhatman's shortcode list for CFv6 and he suggests {var:read_data19}
Bob
If you'd like to buy me a coffee or two, thank you very much
J
jformicola 47
May 28 2021, 14:27 #396577
Thanks, that seems to have done it!