Incomplete documentation for Boolean Custom Fields

Post Reply
kbeezie
Ssr. Bludit
Posts: 28
Joined: Sun May 03, 2026 9:20 pm
Location: Grand Rapids, Michigan, USA
Has thanked: 2 times
Been thanked: 8 times
Contact:

I was reading the documentation here regarding custom fields.

https://docs.bludit.com/en/content/custom-fields

Which shows there is a 'default' option, however for boolean operator default doesn't work be it "true", true, "1" , or 1 to have the check box enabled by default on new content creation.

Code: Select all

[
    {
        "name": "vgd_show_in_menu",
        "type": "bool",
        "label": "Show Page in Navigation",
        "default": "true",
        "tip": "Toggle whether this page appears in the navigation menu."
    }
]
I dug into new-content.php to see the following:

Code: Select all

                <?php if (!empty($site->customFields())) : ?>
                        <div id="nav-custom" class="tab-pane fade" role="tabpanel" aria-labelledby="custom-tab">
                                <?php
                                $customFields = $site->customFields();
                                foreach ($customFields as $field => $options) {
                                        if (!isset($options['position'])) {
                                                if ($options['type'] == "string") {
                                                        echo Bootstrap::formInputTextBlock(array(
                                                                'name' => 'custom[' . $field . ']',
                                                                'label' => (isset($options['label']) ? $options['label'] : ''),
                                                                'value' => (isset($options['default']) ? $options['default'] : ''),
                                                                'tip' => (isset($options['tip']) ? $options['tip'] : ''),
                                                                'placeholder' => (isset($options['placeholder']) ? $options['placeholder'] : '')
                                                        ));
                                                } elseif ($options['type'] == "bool") {
                                                        echo Bootstrap::formCheckbox(array(
                                                                'name' => 'custom[' . $field . ']',
                                                                'label' => (isset($options['label']) ? $options['label'] : ''),
                                                                'placeholder' => (isset($options['placeholder']) ? $options['placeholder'] : ''),
                                                                'checked' => (isset($options['checked']) ? true : false),
                                                                'labelForCheckbox' => (isset($options['tip']) ? $options['tip'] : '')
                                                        ));
                                                }
                                        }
                                }
                                ?>
                        </div>
                <?php endif ?>
'default' is not used when creating boolean custom fields, but rather checked is.

So I had to change my custom field entry to

Code: Select all

[
    {
        "name": "vgd_show_in_menu",
        "type": "bool",
        "label": "Show Page in Navigation",
        "checked": true,
        "tip": "Toggle whether this page appears in the navigation menu."
    }
]
and then it would work. Probably something to update on the documentation (or change the behavior of boolean to look for the 'default' option, but make a note that the value should be a boolean true or false (no string quotation) in the json.

Came across this because I'm building my own theme to allow for some theme-based toggles or declarations on the content so that a user doesn't neccessarily have to dive into editing the theme files.

Though would be nice if either could happen (if not already possible)

- the ability to define custom fields to show up from the theme's functions.php (if it won't somehow conflict with someone already putting something into the custom fields text box in the admin panel)

- the ability to create site-wide custom fields that may either show up under "General", or "Theme Options" , so that a user may be able to change small things such as theme accent colors, layout choices, or other small tweaks.
Post Reply