Forums

How do I hide the heading of empty fields from sent emails

carramone 17 Mar, 2022
Hi
I have a forms with a lot of fields that will never be filled out. Most of them are hidden because they are shown or hidden based on selections the visitor make. Regardless of this, in the sent email ALL the fields are visible. I have tried to setup a "Email Conditions", but I can't get it to work.

I tried this.
{data:my_value} is not empty

and this
{data:my_value} is not NULL
But regardless, the empty field is included as a label in the emails

Best regards
GreyHead 18 Mar, 2022
Hi carramone,

Hidden fields are submitted whether or not they are used. If you disable them instead of hiding them then the data should not be submitted.

Bob
carramone 21 Mar, 2022
Thank you Bob
I tried this but it doesn't work for me. Regardless if the fields are enabled or disabled the headings are included in the email.

When I add the "email conditions" I can remove the fields from being included, problem is I don't know how to include them when the fields are enabled. I tried conditions like this:
enable == 1
enable == yes
enable == "yes"
But neither worked, I tried to find some documentation on the "Email conditions" but I failed😟

Best regards,
GreyHead 21 Mar, 2022
Hi Carramore,

I'm not familiar enough with CFv7 to give you a clear answer :-(

Maybe you could use Custom PHP before the Email action to go through the form data array and remove any entries you don't want.

Bob
carramone 22 Mar, 2022
1 Likes
Thank you Bob.
That is the way I did it in my CF6 forms. So yes, that will probably work.

I found a way to do it with the "email conditions". It was actually quite simple once I got my head around how to think about is. I'll write it down here in bullet form just in case someone else want to do the same.

-----------------HOW TO HIDE AN EMPTY FIELD FROM SENT EMAILS (CF7)------------------------

1. Give your field a unique "Field name". For example "my_unique_field_name"
2. Add the data behavior "email conditions" to you field
3. Click on "Add New Email Condition"
4. As value 1, enter:
{data:my_unique_field_name}
5. In the second column, where is says "==" as default, change that to "is not empty"

Done, now your field will only be emailed if it carries some data.

----------------------------------------------------------------------------------------------------------------------

Best regards,
Carramone
You need to login to be able to post a reply.