Conditional field based on config value?

Hi all!

Is it possible to have a field be shown in the Panel, only when there is/isn’t a set value in the config file? Example: the field should show only if there is no ‘myplugin.default’ value in config.

Nope, that is not possible, unless you create a custom field.

Hmm interesting one. I don’t think you can without making a custom field. However there is a plugin out there that adds extra classes to all the panel elements, with a little creative thinking you might be able to use that idea to get the same effect.

I’m thinking if you make a small plugin that throws a class on the panel body element based on the config value, then you can target the field in question through that class. It’s a little hacky and I don’t know what the side effects might be (off the top of my head if this is a required field and you hide it, you probably wont be able to save the page), but might just work :slight_smile:

Making a custom field that extends all the built in fields properly to add the feature is the way to go though.

That is generally a problem when using conditional fields: Conditional fields: allow `required` · Issue #234 · getkirby/ideas · GitHub