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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Include checkbox options from another file

first-time

Started by Flachy Joe 6 months ago · 9 replies · 131 views
6 months ago

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

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

6 months ago

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?

6 months ago

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: https://learn.getgrav.org/16/cookbook/admin-recipes

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

6 months ago

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

6 months ago

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.

6 months ago

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.

6 months ago

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

6 months ago

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:

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1133 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 107 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 125 7 months ago
Forms & Blueprints · by Rayburn Davis, 7 months ago
4 90 7 months ago