Using when with checkboxes

I am trying to conditionally display fields in the panel, depending on what checkboxes are checked in another field. This is what I have:

          productOptions:
            label: Product options
            type: checkboxes
            required: true
            columns: 2
            options:
              physical: Physical
              digital: Digital
          physicalPrice:
            label: Physical price
            type: number
            steps: 0.01
            before: £
            when:
              productOptions: physical
          digitalPrice:
            label: Digital price
            type: number
            steps: 0.01
            before: £
            when:
              productOptions: digital

But this isn’t working - the price fields are not appearing when the checkboxes are checked. Is a different approach needed for checkboxes? The client needs to be able to choose either physical or digital, or both.

A checkboxes field is not an either/or field, so this won’t work, because it stores a comma-separated list of values.

For two options, where only one should be selected, use a radio field instead.

If the user should be able to select both, then the when option won’t work at the moment.

Understood, thanks for the quick answer.
In this instance a couple of toggles would work just as well, so I will use that approach instead.

Does when works with toggle?
The Documentation says yes, but there is no syntax hint…
I tried like this – but it is not working:

      print:
        label: Available as print
        type: toggle
        default: "nop"
        text:
          - "nop"
          - "yay"
        width: 1/2
      edition:
        label: Part of an edition
        type: toggle
        default: "nöö"
        text:
          - "nöö"
          - "sure"
        when:
          print:
            text: "yay"
        width: 1/2

A toggle button always has the values true or false.

when:
  print: true
1 Like

I see.

print:
   default: false
edition:
   when:
      print: true

That works. Thanks! :smiling_face_with_three_hearts: