Skip to content

Commit 1dcedc4

Browse files
authored
Use booted closure for missing timezone field
1 parent a3f9d9e commit 1dcedc4

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/ServiceProvider.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ public function bootAddon()
1414
Field::computedDefault('default-events-timezone', fn () => Statamic::displayTimezone());
1515
Field::computedDefault('default-event-timezone', fn () => Events::defaultTimezone());
1616

17-
collect(Events::setting('collections', ['events']))
18-
->each(function (string $collection) {
19-
Collection::findByHandle($collection)?->entryBlueprint()->ensureField(
20-
'timezone',
21-
[
22-
'dictionary' => 'timezones',
23-
'max_items' => '1',
24-
'type' => 'dictionary',
25-
'default' => 'computed:default-event-timezone',
26-
]);
27-
});
17+
// has to be in booted so that the `events::event` fieldset is properly registered and loaded
18+
$this->booted(function () {
19+
collect(Events::setting('collections', ['events']))
20+
->each(function (string $collection) {
21+
Collection::findByHandle($collection)?->entryBlueprint()->ensureField(
22+
'timezone',
23+
[
24+
'dictionary' => 'timezones',
25+
'max_items' => '1',
26+
'type' => 'dictionary',
27+
'default' => 'computed:default-event-timezone',
28+
]);
29+
});
30+
});
2831
}
2932
}

0 commit comments

Comments
 (0)