Bug or feature? Editor role can't edit a site.yml part that has a `when` he does not have permission to set himself?

Here is the setup:

  • editor role can edit site.yml without issue.
  • site.yml has a part reserved for admin (a “theme settings” tab)
  • for that I used the double site.yml file technique in a plugin with the following code:
Kirby::plugin('jug/role-specific-site-blueprints', [
    'blueprints' => [
        'site' => function () {
            if (($user = kirby()->user()) && $user->isAdmin()) {
                return Data::read(__DIR__ . '/blueprints/site.admin.yml');
            } else {
                return Data::read(__DIR__ . '/blueprints/site.editor.yml');
            }
        },
    ]
]);

In that site.admin.yml, in the tab that only admin can access there is a setting to choose a “footer style” among several. Let’s say we chose “footer 2”.

In another tab, accessible by both editor and admin, the content can be altered by both of them, but a field is defined like so:

  footerSubContent:
    label: A phrase all the way down under the footer
    type: text
    when:
      footerStyle: footer-02

This field only appears if the “theme setting” “footer style” field is set to footer 2. Pretty straight forward.

The editor can see this field.
But in its “view”, the site.yml does not actually contain a footerStyle setting.

What happens is that he can actually see AND edit the footerSubContent field… but when saving, the modification disappears.

Is that a bug or a feature? And if it’s a feature, is there a better way to do what I described?

Not sure I understand what “the modification disappears” means. I set up a very simple use case in Starterkit, and it seems to work as expected.

These is my test site.admin.yml

title: Site

tabs:
  tab1:
    label: General fields
    fields:
      footerSubContent:
        label: A phrase all the way down under the footer
        type: text
        when:
          footerStyle: footer-02
  tab2:
    label: Admin fields
    fields:
      footerStyle:
        label: Select a footer style
        type: select
        options:
          - footer-01
          - footer-02

And this my site.editor.yml

title: Site

tabs:
  tab1:
    label: General fields
    fields:
      footerSubContent:
        label: A phrase all the way down under the footer
        type: text
        when:
          footerStyle: footer-02

When the admin hasn’t selected anything, or not footer-2, the field in the General tab is not shown for the editor.

Once admin selected footer-02 and saves, an an editor logs in, they can see, edit and save the field.

When I say “the modification disappears” I mean it is not saved. The site.fr.txt is not modified and when the editor admin page refreshes, the modified content visually reverts back to its previous state.

I tested it in my setup with the exact same config as you and the bug persists. But in StarterKit it does not.
So must be something on my hand indeed.
I’ll investigate and report back if it’s due to something I can identify. (it’s a big project, several plugins lots of different things interacting with each others)