How do I email only fields that have been filled

XenEffect 01 Jul, 2015
Hi,

I want to see only fields that have been filled in the email. How do I get it to do that?

I did see a thread with this code in it:
<?php
$email_body = array();
$email_body[] = "<p>Hi {$form->data['name']}</p>";
$email_body[] = 'Some standard text here';
if ( $form->data['some_input'] ) {
  $email_body[] = "<p>Label: {$form->data['some_input']}</p>";
}
// . . . and so on
$form->data['email_template'] = implode("\n", $email_body);
?>

But where does it go ? Does this get added to the form code? or the email template?

Please help

Thanks,
Farsheed
GreyHead 01 Jul, 2015
Hi Farsheed,

I would put it in a Custom Code action before the Email template, then put {email_template} in the Email template.

You could also put it directly in the Email template but I find separating them is a bit tidier.

Bob
XenEffect 01 Jul, 2015
Thanks GreyHead,

should I put that code at the end of the form code (in Custom Code) or at the beginning.

The form is rather long do I have to create a if statement for each field? is there an easier way to do this?

URL: http://moving-storage.net/free-estimate
XenEffect 01 Jul, 2015
Am I suppose to change some values in that code? I don't understand php I do understand HTML and css .. please help me understand this code .. (please explain this like I'm a 5 yr old)
GreyHead 02 Jul, 2015
Hi Farsheed,

You need to change pretty much all the values in that code.

As I said it goes in a Custom Code action in the form ON Submit event before the Email action.

The advice to a five-year old is to get some help from someone else with some coding experience. This isn't particularly difficult but it can't be explained in two minutes in a forum post either.

Bob
XenEffect 02 Jul, 2015
Thank you GreyHead,

I figured it out it would be awesome if you could give me the if statement code for a check box.

I know the code for a text box is:

if ( $form->data['some_input'] ) {
$email_body[] = "<p>Label: {$form->data['some_input']}</p>";
}


I'd really appreciate your help.

Thanks,
Farsheed
GreyHead 03 Jul, 2015
Hi Farsheed,

If you add a Handle Arrays action to the On Submit event and drag it up before your Custom Code/Email that will convert checkbox group values (and multi select dropdown values) to text strings which will out put in the same way as other values - you probably want to set the separator to comma+space.

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