# The 'when' property seems not working in 'select\_one' type

**URL:** <https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219>\
**Category:** Packaging an application\
**Created:** [June 1, 2023, 2:39pm UTC](https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219 "2023-06-01T14:39:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaliy](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/vitaliy/32/763_2.png) [@Vitaliy](https://community.replicated.com/u/Vitaliy)\
**Post date:** [June 1, 2023, 2:39pm UTC](https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219/1 "2023-06-01T14:39:49Z")

</div>

From the documentation:

> The `when` property can be used on groups, items, and `select_one` options.

But seems it’s not working on ‘select\_one’ options or I misunderstood this.  
I have code:

```auto
- name: postgres_host_type
  type: select_one
  title: Postgres Host Type
  default: postgres_hostname
  items:
    - name: postgres_hostname
      title: Postgres Hostname
    - name: postgres_ip
      title: Postgres IP Adress
    - name: embedded_postgres
      title: Embeded Postgres
      when: '{{repl (ConfigOptionEquals "dev_deploy" "true")}}'

```

I want last option ‘embedded\_postgres’ will be shown only when property “dev\_deploy” is “true”, but it’s shown always, no matter “dev\_deploy” is “true” or “false”. What the proper way to achieve this?

I’ve found one post here in community but without answer. [Select\_one and "when"](https://community.replicated.com/t/select-one-and-when/949)

---

<div class="post-metadata">

**Author:** ![Alex\_Parker](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/alex_parker/32/777_2.png) [@Alex\_Parker](https://community.replicated.com/u/Alex_Parker)\
**Post date:** [June 1, 2023, 2:55pm UTC](https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219/2 "2023-06-01T14:55:52Z")

</div>

The word item is overloaded—items are used at the top level (i.e., `postgres_host_type` is an item) and then there are items for the `select_one`. The `when` doesn’t work for the items in the `select_one`. It only works at the top level (if I recall correctly).

So to accomplish this today, you would have to create two `select_one` items. One would have the “Embedded Postgres” option and one would not. Then you would use `when` on each of those two items so that the proper `select_one` shows based on the value of `dev_deploy`.

Something like this (not verifying syntax, so check this before using):

```auto
- name: postgres_host_type
  type: select_one
  title: Postgres Host Type
  default: postgres_hostname
  when: '{{repl (ConfigOptionEquals "dev_deploy" "true")}}'
  items:
    - name: postgres_hostname
      title: Postgres Hostname
    - name: postgres_ip
      title: Postgres IP Adress
    - name: embedded_postgres
      title: Embeded Postgres
- name: postgres_host_type
  type: select_one
  title: Postgres Host Type
  default: postgres_hostname
  when: '{{repl (ConfigOptionNotEquals "dev_deploy" "true")}}'
  items:
    - name: postgres_hostname
      title: Postgres Hostname
    - name: postgres_ip
      title: Postgres IP Adress

```

---

<div class="post-metadata">

**Author:** ![Vitaliy](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/vitaliy/32/763_2.png) [@Vitaliy](https://community.replicated.com/u/Vitaliy)\
**Post date:** [June 1, 2023, 3:09pm UTC](https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219/3 "2023-06-01T15:09:55Z")

</div>

So, it looks like that documentation is not clear enough (at least for me). It says about ‘groups’ (we can make groups optional with ‘when’), about ‘items’, and about `select_one` **options**.

---

<div class="post-metadata">

**Author:** ![Alex\_Parker](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/alex_parker/32/777_2.png) [@Alex\_Parker](https://community.replicated.com/u/Alex_Parker)\
**Post date:** [June 1, 2023, 3:34pm UTC](https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219/4 "2023-06-01T15:34:43Z")

</div>

You’re right, the docs do say that. Someone else asked about this recently, so maybe there’s a regression here. Can you open a support case so that we can investigate and fix if needed or update the docs?

---

<div class="post-metadata">

**Author:** ![Vitaliy](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/vitaliy/32/763_2.png) [@Vitaliy](https://community.replicated.com/u/Vitaliy)\
**Post date:** [June 1, 2023, 3:41pm UTC](https://community.replicated.com/t/the-when-property-seems-not-working-in-select-one-type/1219/5 "2023-06-01T15:41:10Z")

</div>

Thank you Alex. I will create support ticket
