diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 797ed37..a6e71a5 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -14,16 +14,19 @@ public function bootAddon() Field::computedDefault('default-events-timezone', fn () => Statamic::displayTimezone()); Field::computedDefault('default-event-timezone', fn () => Events::defaultTimezone()); - collect(Events::setting('collections', ['events'])) - ->each(function (string $collection) { - Collection::findByHandle($collection)?->entryBlueprint()->ensureField( - 'timezone', - [ - 'dictionary' => 'timezones', - 'max_items' => '1', - 'type' => 'dictionary', - 'default' => 'computed:default-event-timezone', - ]); - }); + // has to be in booted so that the `events::event` fieldset is properly registered and loaded + $this->booted(function () { + collect(Events::setting('collections', ['events'])) + ->each(function (string $collection) { + Collection::findByHandle($collection)?->entryBlueprint()->ensureField( + 'timezone', + [ + 'dictionary' => 'timezones', + 'max_items' => '1', + 'type' => 'dictionary', + 'default' => 'computed:default-event-timezone', + ]); + }); + }); } }