Struggling with Blueprint: Custom header data form in Admin area

I wanted to find a solution that didn’t remove built-in functionality, finally got it to working :sweat_smile: So, we are registering a new permission in our theme.

1. <YourTheme>.php
<?php
namespace Grav\Theme;
use Grav\Common\Grav;
use Grav\Common\Theme;
use Grav\Events\PermissionsRegisterEvent;
use Grav\Framework\Acl\PermissionsReader;
class <YourTheme> extends Theme
{
    public static function getSubscribedEvents()
    {
        return [
            PermissionsRegisterEvent::class => ['onRegisterPermissions', 100],
        ];
    }

    public function onRegisterPermissions(PermissionsRegisterEvent $event): void
    {
        $permissions = $event->permissions;
        $actions = PermissionsReader::fromYaml("theme://permissions.yaml");
        $permissions->addActions($actions);
    }
}
2. add permissions.yaml (in theme root folder)
actions:
  site:
    label: PLUGIN_ADMIN.ACCESS_SITE
    actions:
      login:
        label: PLUGIN_ADMIN.ACCESS_SITE_LOGIN
      private:
        label: Private Area
types:
  default:
    type: access

@Flop, if you still want to use @unset

  • create folder partials in your theme blueprints (<YourTheme>/blueprints/partials)
  • create security.yaml file
  • add the following code
extends@:
  type: partials/security
  context: blueprints://pages

form:
  fields:
    _site:
      fields:
        header.access:
          unset@: true

In any case, i would prefer to register the permission first, as it allows you to manage the user’s permissions through admin panel.