Save a boolean instead of a String in Admin hidden field

Hi,

I’m looking to add for a modular blueprint cache_enable:false for each modular saved from the admin panel.

I’m using:

header.cache_enable:
  type: hidden
  default: false

But it doesn’t save it in the generated markdown file. I must use:

header.cache_enable:
  type: hidden
  default: 'false'

But it outputs:

title: 'My Modular’
cache_enable: ‘false’

Anyway to force a Boolean to be saved?
Thanks

When in doubt, look at the blueprints for Grav itself. The system/blueprints/config/system.yaml is particularly illuminating:

                home.hide_in_urls:
                      type: toggle
                      label: PLUGIN_ADMIN.HIDE_HOME_IN_URLS
                      help: PLUGIN_ADMIN.HIDE_HOME_IN_URLS_HELP
                      highlight: 0
                      options:
                          1: PLUGIN_ADMIN.YES
                          0: PLUGIN_ADMIN.NO
                      validate:
                          type: bool

In bit you actually need to force it being saved as a boolean is that validate: type: bool bit.

Good tip, thanks :slight_smile:

I actually did it this way for those who are interested:

header.my_value:
  type: hidden
  label: Label Name
  default: 0
  validate:
    type: bool