Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Save a boolean instead of a String in Admin hidden field

Started by Muut Archive 10 years ago · 3 replies · 467 views
10 years ago

Hi,

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

I'm using:

YAML
header.cache_enable:
  type: hidden
  default: false

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

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

But it outputs:

TXT

title: 'My Modular'
cache_enable: 'false'

TXT

Anyway to force a Boolean to be saved?
Thanks

10 years ago

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

YAML
                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.

10 years ago

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

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1349 9 years ago
Archive · by Muut Archive, 9 years ago
2 934 9 years ago
Archive · by Muut Archive, 9 years ago
2 4060 9 years ago
Archive · by Muut Archive, 9 years ago
1 2946 9 years ago
Archive · by Muut Archive, 9 years ago
3 1118 9 years ago