Include checkbox options from another file

Hi,

I’m Grav beginner and I’d like to give to some editors an access only to checkbox options, preventing them to change the form structure and checkboxes labels.

I currently have this form

title: 'Inscription'
published: true
visible: true
form:
    name: inscription
    fields:
        perso:
            type: section
            title: 'Personal information'
            fields:
                name:
                    label: Name
                    type: text
                    validate:
                        required: true
        choices:
            type: section
            title: 'Select at least one case'
            fields:
                firstOption:
                    label: 'Option 1'
                    type: checkboxes
                    options:
                        0802-0808: '08-02 to 08-08 2026'
                secondOption:
                    label: 'Option 2'
                    type: checkboxes
                    options:
                        0412-0418: '04-12 to 04-18 2026'
                        0419-0425: '04-19 to 04-25 2026'

Is it possible to create the date options from another file?

You could create a very simple plugin with a static method and then use it to fill options with data-options@

Thank for the interest.
So I have to write a PHP function which read the file and return the options?

It can’t simply read the data from a yaml?

I find exactly what I need and very easy to use:
@Karmalakas you point me in the good direction withdata-option@ but I’m using config-options@ with a custom YAML file as described here: Admin Recipes | Grav Documentation

But now I have to set the permissions to allow my editor group to change only this config page :grimacing: Can someone help?

Ok, I’ve seen this https://stackoverflow.com/questions/79040787/how-do-i-add-a-custom-permission-for-a-custom-configuration-area-to-the-grav-adm

So it’s not possible to set the permission for a specific config page. That’s why @Karmalakas tell me to create a plugin, yes?

That post is about a different problem I think. Or I completely misunderstood what you’re asking. Can you clarify?

My visitor have to choose one (or more) date by checking a box.
My editor have to enter the dates the visitor can check.
I 'd like my editor can only change this configuration, without any other access to admin.

I tried to write a plugin, it works well but the page to enter dates resides in this plugin configuration so I’d have to allow editor to access the plugin area.

I tried the stackoverflow solution linked above with a plugin to tweak the permissions of a custom configuration page but I can’t get it working, nothing appear in the admin menu.

So now I’m back in the user/config/site.yaml extension by a user/blueprints/config/site.yaml file and I give the editor access to this page.

Oh, I’ve an idea: can user/blueprints/config/site.yaml crush the user/config/site.yaml with condition? So in the case the editor access it, it display only the date config but if another admin does it extends the original page.

@FlachyJoe, Instead of investing a lot of time and effort to prevent the user from doing anything wrong by boarding everything up, you might consider informing/educating the user about what to do, what not and its consequences.

I like the adage of the Python community: We are all adults.

You’re obviously right but if I warn the editors about any possible misconfiguration in the admin panel then they won’t log in ever and will ask me to edit for them… :face_with_bags_under_eyes: