Process array in Email & custom code

ljk 09 Sep, 2016
Hi,

I am following this tutorial: http://www.chronoengine.com/faqs/70-cfv5/5226-how-can-i-have-a-button-to-add-more-form-inputs-2.html. I have the fields showing up properly and the debugger is showing the fields for the recipient array have the correct values, but I can't figure out what to use to get the fields to display in the event email or what to use in the event custom code to get at a particular field in the recipient array.

This is the form: http://www.croatiancentre.com/index.php?option=com_chronoforms5&chronoform=Dancer-Registration-Form. Each Dancer has a last name, given name, sex, etc.

In my custom code event I want to get the first dancer's last name and given name. This is how I would normally get a field:
  $jinput = JFactory::getApplication()->input;	
  $email = $jinput->getString('family_email', '', 'post');

which will give me the family email address in the $email variable. I have tried a number of different things to get the first dancer's info such as:
  
  $name = $jinput->getString('recipient', '', 'post');
  $lastname = $jinput->getString("[recipient][1]['lastname']", "", "post");
  $form->data['fromname']  = $name[1]['lastname'];

But I get Illegal string offset 'lastname' as a warning when I submit the form. How do I access the first dancer's fields in the recipient array in the custom code?

The other issue is how to access these fields in the email template output. I have tried things like:
{recipient}[1]['lastname']
{recipient}{1}{'givenname'}
['recipient']['1']['allergies']

but none of that works. What do I use to get at the various dancer's fields in the recipient array? I want to have the following code for each dancer in the email:
<table>
<tr><th>Dancer 1 Information</th><th></th></tr>
<tr><td>Last Name</td><td>{recipient}[1]['lastname']</td></tr>
<tr><td>Given Names</td><td>{recipient}{1}{'givenname'}</td></tr>
<tr><td>Sex</td><td>{recipient[1]['sex']}</td></tr>
<tr><td>Birth Date</td><td>{recipient[1]['birthday']}</td></tr>
<tr><td>Mobile Phone</td><td>{recipient[1]['mobile']}</td></tr>
<tr><td>Email</td><td>{recipient[1]['dancer_email']}</td></tr>
<tr><td>Allergies or illnesses</td><td>['recipient']['1']['allergies']</td></tr>
...</table>


Here is the output that I get from the debug message:[attachment=0]Dancer-Registration-Form-output-1.jpg[/attachment]

Let me know if you need the form code.

Thank you for your help.
GreyHead 18 Nov, 2016
Hi Ljk,

Sorry for the very late reply :-( Did you resolve this?

CF adds the form data (and any URL data) to the $form->data array so you should be able to access the value from there. Adding a Debugger action temporarily will show you what data is available.

Bob
This topic is locked and no more replies can be posted.