Showing a label only when the field is filled
“Phone:” only appears when there's a number
No mobile number, only the phone; no phone, only the mobile number – with no separator and no empty label.
What it's about
- Each label hangs on a rule: [Phone:{LabelPhone}] only shows when Phone is filled.
- The separator only shows when both numbers are there: [&Phone&Mobile: | ].
- “Phone: ” comes from a hidden helper field, because a second colon in the rule text empties the box.
Transcript
Click a timestamp to jump to that point in the video.
- The buyer leaves the Mobile field empty. Now the card shows only the phone – no separator, no empty label.
- And the other way around: without a phone number, only the mobile number shows.
- Behind it are three rules in the box content. The first: if there's a phone number, the label goes in front of it. The second: only when Phone and Mobile are both filled does the separator go in between. The third does the same for Mobile.
- Why isn't the label simply written as text in the rule? Then the bracket would have a second colon. And a second colon empties the whole box – with no error message. That's why the label comes from a helper field.
- In the back end, open the print template in the layouter, pick the box Contact, and click Inhalt bearbeiten. The three rules are in the first line.
- You set up the helper fields in the Special Field Options. LabelPhone is hidden – the buyer never sees it. Its default text is the label: Phone, colon, space.
- Here's how it looks live.
- Label and separator only show up where there's a number.