I used this entry from the FAQ to add more form inputs.
Now my question is how can I output them in the thanks message?
Here is the output of the debugger:
[recipient] => Array
(
[1] => Array
(
[name] => Max Mustermann
[mail] => max@mustermann.de
[taetigkeit] => Test
)
Can you please help me?
Regards and TIA
Steffen
You could use the Action Custom Code inside the On Submit Event.
There you can output any form data that is submitted:
<?php
echo "Name: $_POST[name]<br />";
echo "Mail: $_POST[mail]<br />";
echo "Tätigkeit: $_POST[taetigkeit]<br />";
?>
Or simply add
Name: {name}
Mail: {mail}
Tätigkeit: {taetigkeit}
to the Action Show Thanks Message.
Patrick
thanks for your answer.
but which "name" would ChronoForms show, because I have a lot of "name" fields in that array!?!
Regards
Steffen
I have not read the FAQ you pointed to, but each field must have an unique name anyway.
There shouldn't be two textfields named "name" in the same form(?)
Patrick
therefore it´s within an array.
It´s like recipient[1].name
Here is the code from the FAQ:
<?php
// set the total count
$count = 5;
for ( $i = 1; $i <= $count; $i++ ) {
// add classes which will let us identify the inputs to hide
if ( $i == 1 ) {
$class = 'show_me';
} else {
$class = 'hide_me';
}
// add the 'Add one' buttons (but not to the last set)
if ( $i < $count ) {
$j = $i+1;
$button = "<div><input type='button' name='addone_{$j}' id='addone_{$j}' value='Add one' class='add_one' /></div>";
} else {
$button = "";
}
// add the inputs with a little ChronoForms styling
echo "<div id='recipient_{$i}' class='{$class}' >
<div class='multiline_start'>
<label>Name</label>
<input type='text' name='recipient[{$i}][name]' id='recipient_{$i}_name' />
</div>
<div class='multiline_add'>
<label>Address</label>
<input type='text' name='recipient[{$i}][address]' id='recipient_{$i}_address' />
</div>
<div class='clear' ></div>
{$button}
</div>";
}
?>
Thanks,
Steffen
Either version should work. With Sloan's you have to add each entry that you need; Steffen's PHP version can be set to check how many entries have been completed and only show those.
Bob
sorry but I guess you missunderstood something. I'm the one with the questions, Patrick gave me some hints.🙂
Can you tell me, how to deal with php in this case!? I want to show all filled "recipients" in my thanks message.
Regards and TIA
Steffen
Oops . . . sorry, that's what happens when I post late at night or early in the morning.
I would use a Custom Code action with something like this in it:
<?php
$r_info = array();
foreach ( $form->data['recipients'] as $r ) {
$r_info[] = "<div>Name: {$r['name']}; Email: {$r['email']}; ??: {$r['taetigkeit']}</div>";
}
$form->data['recipient_info'] = implode("\n", $r_info);
?>
Then put {recipient_info} into the email template.Bob
I tried this, but I can't see any output in the thanks message:
<?php
$r_info = array();
foreach ( $form->data['recipient'] as $r ) {
echo "<tr><td> </td><td>{$r['name']}, {$r['mail']} <br /> {$r['taetigkeit']} {$r['stufe']} </td></tr>";
}
?>
What´s wrong with my code!?
In the Debugger output I have something like that:
)
Validation Errors:
Array
(
)
data['recipient'] as $r ) { echo ""; } ?>
Thank you for your patience with me...
Regards
Steffen
Have you tried doing what I suggested? Your code is very different.
Where have you put your code? You can't use PHP in the Thank You age action.
Bob
Have you tried doing what I suggested? Your code is very different.
No, because I want the info about the recipient in a table and not in a div and I need it in the Thank You page.
Where have you put your code? You can't use PHP in the Thank You page action.
Didn't know that. So I will try what you suggested and change the div to table.
Thanks again!
Regards,
Steffen
sorry, it´s me again.
I still have problems with that.
I added this in a custom element on the form:
<?php
$r_info = array();
foreach ( $form->data['recipient'] as $r ) {
$r_info[] = "<tr><td> </td><td>{$r['name']};, {$r['mail']}; <br /> {$r['taetigkeit']}; {$r['stufe']};</td></tr>";
}
$form->data['recipient_info'] = implode("\n", $r_info);
?>
My thanks message looks like this:
<html>
<head>
<meta name="generator"
content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
<title></title>
</head>
<body>
<table cellpadding="5" cellspacing="5" border="0">
<tr>
<td colspan='2'>
<h2>Vielen Dank für deine Anmeldung zur Veranstaltung "{ver}".</h2>
<p>Du wurdest mit folgenden Daten angemeldet:</p>
</td>
</tr>
<tr>
<td colspan='2'>
<h3>Veranstaltung</h3>
</td>
</tr>
[...]
<tr>
<td>
<strong>Ich benötige Kinderbetreuung</strong>
</td>
<td>{kinderbetreuung}</td>
</tr>
<tr>
<td colspan='2'>
<h3>weitere Personen</h3>
</td>
</tr>
{recipient_info}
</table>
</body>
</html>
But nothing is shown in the thanks message...😟
Thanks,
Steffen
a) Please remove the <html> and <body> tags from the Thanks message.
b) Please check that the Custom Code action is before the Thanks Message action.
c) Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Bob
we are getting closer...😉
It worked now, but there is still one problem left. Somehow the "foreach" doesn't work, because he is creating an array entry for every single field also if it´s empty...!?
Here is my debugger output:
Data Array:
Array
(
[option] => com_chronoforms
[ver] => test
[anreise] => 07.11.2013 17:33
[abreise] => 09.11.2013 13:00
[chronoform] => Anmeldeformular
[event] => submit
[name] => myname
[joomla_name] => myusername
[geburtsdatum] => mybirthdate
[adresse] => mystreet
[plz] => mypostalcode
[ort] => mycity
[telefon] => myphone
[handy] => mymobile
[email] => mymail
[Taetigkeit_Stufe] => Vorsitzender
[stufe] => Diözese
[stamm] => mystamm
[vegetarier] => Nein
[allergien] => Test
[kinderbetreuung] =>
[participant] => Array
(
[1] => Array
(
[name] => Max Mustermann
[mail] => max@mustermann.de
[taetigkeit] => Mustername
[stufe] => Test
)
[2] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[3] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[4] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[5] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[6] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[7] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[8] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[9] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
[10] => Array
(
[name] =>
[mail] =>
[taetigkeit] =>
[stufe] =>
)
)
[chrono_verification] => LWJVC
[input_submit_31] => Zustimmen & Anmelden
[b0368c24f6a254a29579b160951c5f9f] => 1
[participant_info] => Christian Knoll, ck@dpsg-speyer.org
Kurat Diözese
,
,
,
,
,
,
,
,
,
)
Validation Errors:
Array
(
)
You are putting your code in an Element, not an action.
You are totally right, that was my big fault.
But I changed that and now it worked. The only problem - as I described before - is that it shows all array items in thank you message even if they are empty.
Thanks,
Steffen
To skip the blank entries the foreach needs to be a little more sophisticated (based on my earlier post):
<?php
$r_info = array();
foreach ( $form->data['recipients'] as $r ) {
if ( $r['name'] || r['email'] || $r['taetigkeit'] ) {
$r_info[] = "<div>Name: {$r['name']}; Email: {$r['email']}; ??: {$r['taetigkeit']}</div>";
}
}
$form->data['recipient_info'] = implode("\n", $r_info);
?>
Bob