You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a subscriber that extends the blueprint of every entry on EntryBlueprintFound.
I'm running into a Duplicate field [seo_section_title_description] on blueprint [pages]. This is the same issue I talked about here: #4286. The workaround we came up with comes with its own problems. Which is why I dug a little deeper so I can confidently reproduce the initial issue.
The problem only seems to happen on multi-sites. On multi-sites, the EntryBlueprintFound event gets triggered for every locale of an entry. So if you add to the blueprint in the event like $event->blueprint->setContents($contents), it will throw the exception the second time this method is called.
The simple workaround was to use ensureFieldsInSection() instead. But the problem with this method is that it ensures all the fields for every locale. This wouldn't be an issue per se, as it clears out duplicate fields when it renders the blueprint. But in my case, it is a problem. That's because I need to add different default values to the blueprint fields for every locale. And because any duplicate ensured fields get stripped out, I end up with the wrong fields. I hope this makes sense.
How to reproduce
Create a multi-site and configure a collection to use at least two sites
Set the blueprint content on EntryBlueprintFound
Visit an entry in the CP
See it throw the duplicate fields error
Logs
No response
Versions
Statamic 3.2.24 Pro
Laravel 8.74.0
PHP 8.0.13
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered:
I've got my problem solved with this workaround. But it feels very yacky.
/*** Add the fields to the entry blueprint in the CP. But only for the current localized entry.* This is to prevent that every localization adds fields to the blueprint.* If we don't do this check, we can't add fields based on entry localization correctly.*/if (Str::containsAll(request()->path(), [$event->entry?->id(), config('cp.route', 'cp'), 'collections', 'entries'])) {
$event->blueprint->ensureFieldsInSection($this->blueprint($event)->items(), 'SEO');
}
Bug description
I've got a subscriber that extends the blueprint of every entry on
EntryBlueprintFound
.I'm running into a
Duplicate field [seo_section_title_description] on blueprint [pages].
This is the same issue I talked about here: #4286. The workaround we came up with comes with its own problems. Which is why I dug a little deeper so I can confidently reproduce the initial issue.The problem only seems to happen on multi-sites. On multi-sites, the
EntryBlueprintFound
event gets triggered for every locale of an entry. So if you add to the blueprint in the event like$event->blueprint->setContents($contents)
, it will throw the exception the second time this method is called.The simple workaround was to use
ensureFieldsInSection()
instead. But the problem with this method is that it ensures all the fields for every locale. This wouldn't be an issue per se, as it clears out duplicate fields when it renders the blueprint. But in my case, it is a problem. That's because I need to add differentdefault
values to the blueprint fields for every locale. And because any duplicate ensured fields get stripped out, I end up with the wrong fields. I hope this makes sense.How to reproduce
EntryBlueprintFound
Logs
No response
Versions
Statamic 3.2.24 Pro
Laravel 8.74.0
PHP 8.0.13
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: