Forums

How to get data in emailform after adding more form inputs in a form

keske 14 Jul, 2015
Hello,

I added the feature like explaned in this turtorial on Chronoengine (http://www.chronoengine.com/faqs/70-cfv5/5226-how-can-i-have-a-button-to-add-more-form-inputs-2.html) and that all is working except for the last part: I don't know how to get the data which is filled in in the form in to the email.

The turtorial says: The resulting data is returned as a sub array in $form->data['recipient'] and may need further processing before it can be saved or used in an email.
But I do't know what tot do the get it working.

Thanks a lot in advance, Kees
GreyHead 14 Jul, 2015
Hi Kees.

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here so that we can see what data you are starting with.

Bob
keske 14 Jul, 2015
Hi Bob,

Thank you.

I used some fields in the table of the mail as you see below, but that didn't work of course. This is still in there.

<tr>
<td>Gezinslid toevoegen</td>
<td>{recipient[][name]}</td>
</tr>
<tr>
<td> </td>
<td>{recipient[][address]}</td>
</tr>
<tr>
<td> </td>
<td>{recipient[][burger]}</td>
</tr>

This is private content

GreyHead 14 Jul, 2015
Hi Kees,

It looks as though you have a Handle Arrays action in the form - that is giving the Array,Array,. . . result. Please remove that for the moment and re-paste the Debugger output for [recipients]

Bob
keske 14 Jul, 2015
Hi Bob,

Thank you, here it is:

This is private content

GreyHead 15 Jul, 2015
1 Likes
Hi keske,

I would add a Custom Code action like this
<?php
$output = array();
foreach ( $form->data['recipient'] as $r ) {
  if ( !empty($r['name']) ) {
    $output[] = "<p>Name: {$r['name']} Address: {$r['address']} Burger: {$r['burger']}</p>";
  }
}
$form->data['recipient_info'] = implode("\n", $output);
?>
then add {recipient_info} to the email template.

You can edit the HTML in the output line to suit your needs.

Bob
keske 15 Jul, 2015
Thanks a lot Bob,

Works pefect!

Just bought you an bee.. uhh, sorry a coffee.

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