Exclude blank fields from notifications [RESOLVED]

Hi all,

I’m moving over from Contact Form 7 to Gravity Forms. One feature that CF7 has that would be really helpful for Gravity Forms is the ability to remove lines from email notifications that contain blank tags.

Basically, let’s say on the form we use there’s an optional field called Additional Remarks. If the field is not needed (and not filled in), that entire line does not send in CF7 if the option to exclude the lines is selected. So instead of having a random line in my email notifications saying "Additional Remarks: " when there’s nothing filled in, the form would just remove that line entirely.

It’s not a huge deal, but it would help the style of my forms being sent out.

Thanks!

By default, fields which have no input when the form is submitted are not included in the notification email when using the {all_fields} merge tag. In fact, you need to use the :empty modifier for the {all_fields} merge tag to include form fields with no submitted value:

If you’re not using the {all_fields} helper, please show us how you have configured the notification. You can probably use the conditional shortcode in your notification if you are using individual merge tags, to exclude one that is submitted without the optional value. Thank you.

My use case is to have pre-formatted emails for distributing download links for products so that the user only has to input a couple fields and Gravity Forms would send the email with text and formatting.

So in our case we’d have a field for Recipient Name, Email, Link, and then some optional fields such as Additional Notes.

So in the notification email it would say:

Thanks for your business, here’s your link: {ShareFile Link:11}

Additional Remarks: {Additional Remarks::13}

What I would like is for that whole line with Additional Remarks to not be sent if blank. On CF7 this is a built-in option and it would be beneficial to have it as such on Gravity Forms.

I will tinker with conditional shortcodes as this seems to have options to accomplish this.

Thanks!

This conditional shortcode will hide the whole line if there were no Additional Remarks submitted in field 13:

[gravityforms action="conditional" merge_tag="{:13}" condition="isnot" value=""]Additional Remarks: {Additional Remarks::13}[/gravityforms]

The rule there is "isnot" "empty". If it’s not empty, your "Additional Remarks: " heading and the submitted value will be shown.

You may end up with a blank line there due to the whitespace around the conditional shortcode. You can edit it so that the whitespace is inside the conditional shortcode, and there are no blank lines outside the shortcode.

1 Like

This did the trick thank you!

1 Like