How to reference elements in a PHP email template

garou

New Member
Hi Folks,

I know from Google searches that this topic has popped up in various forms before, however the explanations always seem to assume that the forms being created in Fabrik and used on a website are storing their information in tables when the user clicks "submit".

I am not doing this for a few forms that I have created, and I am sending the output directly to an email using the Plug-ins function of the form.

So I have tried using the various solutions I have found here in the forums already, but every time I use them, using the syntax: <?php echo$this->emailData['some_element_name'];?> to output the value of an element into my email template, I just get an error message in the email that is sent telling me that there is an "undefined index" with the same name as the element I have used in the PHP echo statement.

So I am wondering whether there is a different syntax you need to use to echo out the value of a form element when you aren't using table?

I know I can just do this with placeholders, but ultimately I want to be able to output repeating groups to email and that requires that I use PHP and not just the standard placeholders.

So any insight that anyone can provide would be very helpful.

Duncan
 
Thanks for that Hugh,

It has certainly solved part of the problem.

I think I am working off an older example you gave to someone about doing this. But when I use the exactly you provided for figuring out how many times to loop the element I encounter a new error.

I'm using your example of:

<?php
$repeats=$this->data['jrnl_Citation'][45];
for($repeat=0;$repeat<$repeats;$repeat++){
?>
<table>
<tr>
<td>Your title:</td>
<td><?phpecho$this->emailData['___jrnl_Year'][$repeat];?>
</tr>
<table>
<?php
}
?>

The problem is that the first line now gives me an error message: Undefined index: jrnl_Citation in <PATH TO MY TEMPLATE FILES>/repeat_journal_request.php on line 45

I tried putting the 3 underscores before the group name the way you suggested with the element, but that didn't make any difference.
 
Use $this->data['fabrik_repeat_group'][x] as the repeat count, where x is your numeric group ID. Just replace jrnl_Citation with fabrik_repeat_group in your original code.

-- hugh
 
Hi Hugh,

Thankyou for that. That is the syntax I am using. I made use of a previous example you had provided in this forum.

So my section of code looks like this currently:

<?php
$repeats = $this->data['jrnl_Citation'][45];
for ($repeat=0; $repeat < $repeats; $repeat++) {
?>
<table>
<tr>
<td>Your title:</td>
<td><?php echo $this->emailData['___jrnl_Year'][$repeat]; ?>
</tr>
<table>
<?php
}
?>

This is in my email template file. But when the form is processed and emailed through where that code is I get this error message in the body of the email that comes to me:

Notice: Undefined index: jrnl_Citation in /home/librarym/public_html/libtest/hsld/plugins/fabrik_form/email/tmpl/repeat_journal_request.php on line 40

With line 40 being the first line of the code : $repeats = $this->data['jrnl_Citation'][45];

I have double checked that I have the right group name and ID number, and that group is set to repeat.

Any thoughts?

Duncan
 
Damn. You would think I couldn't read English properly.

Thank you for that, I was completely miss reading your previous email. As expected, it now works.

Thank you for your help.

Duncan
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top