Possible to show field based on number of files?

I was wondering if there’s a way to show a select based on the number of files in a field like so:

files:
  type: files
display:
  type: select
  when: files.count > 1
  options:
    inline: Inline
    gallery: Gallery

I was wondering if I am doing this wrong or if it just isn’t possible?

No, that’s not possible. You can only use conditional fields with actual values in other fields like described in the docs. There are, however, several requests to extend such conditions in the ideas repo you might want to upvote.

Another option is a custom Panel field.

1 Like

Thank you @texnixe - by this do you mean a custom field plugin? https://getkirby.com/docs/reference/plugins/extensions/fields

Yes, extending the select field in this case.

Is this still true? I want to show a field only if a field of the same page isn’t empty, e.g.

  sidebar:
    width: 1/3
    sections:
      fields:
        type: fields
        fields:
          info:
            type: info
            text: "Diesen Beitrag <a href='{{ page.facebook_url }}' target='_blank'>auf Facebook</a> öffnen."
            when:
              facebook_url: true
          date:
            type: date
      files:
        type: files

yes

1 Like

GitHub - rasteiner/k3-whenquery: Conditionally show fields and sections. Better. can do stuff like that, but since it is JS-based a malicious panel user can circumvent it and still read and write to all fields.

I didn’t post a link to the plugin because I don’t think it is still compatible with current versions of Kirby, plus it has been removed from the plugins’ directory.