---
title: "Display a field only if it matches a condition"
canonical: "https://support.passcreator.com/space/KB/324370433/Display%20a%20field%20only%20if%20it%20matches%20a%20condition"
format: markdown
---
> Macro (toc)

## How conditions for visibility work

If you want to hide or show a field on your pass based on a certain condition, you can specify such a condition by using the syntax explained below.

To add a condition, click on “Extended options” when editing a field using the template editor in Passcreator.

![image](media://d7b7485f-f05e-43a7-ac3e-99e3ee398a60)

Conditions are fault tolerant to a certain degree. E.g. it doesn’t matter if you add whitespaces after the comparison operator or not or if you enclose a string in double or single quotes.

Multiple conditions can be combinded using the && operator.  
The following example matches if the the Level is Silver and the interest additional property contains food or dining.

```
{Level} == Silver && {interest} |= food,travel
```

## Examples

### Show a field if a certain additional property is not empty

To make sure a field is only added to the pass if it contains a value (which means it’s not empty), just enter the placeholder of the additional property in the condition field.

E.g. 

```
{Fieldname}
```

Entering the placeholder only is the same as comparing it to an empty string:

```
{Fieldname} != ''
```

### Show a field if an additional property has a certain value

If you only want to display a field on your pass if an additional property contains a specific value, e.g. if the level of a user is “Silver”, you can add the following condition:

```
{Level} == 'Silver'
```

### Show a field if an additional property value does not match a certain value

If you only want to display a field if an additional property does not match a specific value, add a condition like the following:

```
{Level} != 'Silver'
```

This is the same as

```
{Level} <> 'Silver'
```

### Show a field if an additional property contains a certain value

If you only want to display a field if an additional property contains a value, add a condition like the following. Multiple values can combined using a comma. If one of the values is contained, the conditions matches. The following will match if the field for the pass in question contains either food or travel or both.

```
{interest} |= food,travel
```

### Show a field based on the time when a pass was generated

Using the now() function you can show or hide a field based on the time when the pass was created or updated. When a phone receives an update, the pass is technically recreated. This is when the condition is evaluated.

The following condition will only add a field to the pass if the pass was generated after 2023-10-15 15:00 but before 2023-12-31 23:59.  
Everyone that downloaded the pass before or after these dates won’t see the date. If you send an update or a push notification to your passes on January 1st of 2024, the field will be removed as well automatically.

```
now() > 2023-10-15 15:00 && now() < 2023-12-31 23:59
```

### Show a field based on the operating system of the phone the pass is saved on

If you want to show or hide certain fields on iOS or Android, you can use the following conditions:

#### Only show a field in Apple Wallet (iOS)

```
{operatingSystem} == 'iOS'
```

#### Only show a field on Android phones

```
{operatingSystem} == 'Android'
```