Conditional field depending on status of files section

Hi there,

I want to make a panel field conditional with the when property. Generally, I understand that the syntax is

when:
  myField: myValue

However, in my case I want to make the field appear whenever there are images in a gallery files section. Is there a simple way to do that?

Thanks!

No, there is no way to achieve this (by default).

Idea for a workaround worth testing: When a file is uploaded, update the page with a hidden field (using a file.create:after hook) and use this field value to determine if the other field should be shown. Don’t know if this works without refreshing the page, though.

You would have to update the field value when files are deleted.

Thanks, I will look into this. If this requires refreshing the page it would be not usable for me.

I might open a feature request for this on GitHub, as I think it might make sense to give the when property some extra power (also it would be useful to allow triggering when a certain field does not have a certain value).

There are already multiple feature request for conditional fields! Please check them out before you open yet another one.