Empty Lines in Address Data

I wondered if there was a clever fix for rendering addresses in email notifications when some of the fields are incomplete? For example, it’s quite common for people to skip the “Address Line 2”.

In the email notification, this omission will render as a blank line. This not only looks ugly but it also makes it difficult for people copying and pasting the data to collect the address cleanly.

Is there a smart way to collapse the address data so that empty fields do not render at all?

Thanks

This is possible with Gravity Forms’ conditional shortcodes:

For Addresses specifically, here’s what I use:

{Address (Street Address):1.1}[gravityforms action="conditional" merge_tag="{Address (Address Line 2):1.2}" condition="isnot" value=""]
{Address (Address Line 2):1.2}[/gravityforms]
{Address (City):1.3}, {Address (State / Province):1.4} {Address (ZIP / Postal Code):1.5}
{Address (Country):1.6}

Note how the the shortcode starts on the same line as the Street Address merge tag, includes a line break before the Address Line 2 merge tag, and a line break afterwards. This preserves the formatting whether there is an Address Line 2 or not.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.