Skip to content

Modifying the blueprint in EntryBlueprintFound not working properly #11916

@simonerd

Description

@simonerd

Bug description

Modifying the blueprint in the EntryBlueprintFound event doesn't seem to have any effect. The docs state:

"You may modify the blueprint here and it will be reflected in the publish form (and wherever else a blueprint is used)".

However, I find that nothing seems to change in my case.

Our use case would be to utilize this event to use one blueprint in multiple collections. We're trying to separate otherwise identical content into multiple collections for performance, permission and usability reasons. We want to avoid copy-pasting blueprint files. Fieldsets don't include tabs and sections and our relevant blueprint is a bit more complex, so we don't have many (native) options.

Example
Assume a fresh Statamic 5 install. We have a pages collection with a page blueprint and create a subpages collection, with a subpage blueprint. What we actually want to achieve is that the latter should use the same blueprint as the former, so collections.pages.page instead of collections.subpages.subpage. I can use the event to hook into the blueprint discovery process and adjust accordingly:

Event::listen(EntryBlueprintFound::class, function ($event) {
    // simplified
    if ($event->blueprint->handle() === 'subpage') {
        $event->blueprint = Blueprint::find('collections.pages.page');
    }
});

However, modifying $event->blueprint does not have any effect.

Expected behaviour: Opening or creating an entry in the subpages collection should use the pages.page blueprint.

Actual behaviour: Opening or creating an entry in the subpages collection uses the subpages.subpage blueprint.

I also tested a less-offensive thing than overwriting the blueprint:

$event->blueprint->setHidden(true);

Expected behaviour: When opening the collection index the (relevant) blueprint should not be available in the "Create Entry" menu.

Actual behaviour: The (relevant) blueprint is still available in the "Create Entry" menu.

How to reproduce

See in description above.

Logs

Environment

Environment
Application Name: Statamic
Laravel Version: 12.19.3
PHP Version: 8.3.8
Composer Version: 2.8.9
Environment: local
Debug Mode: ENABLED
URL: statamic5.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Statamic
Addons: 1
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.58.1 Solo

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions