Closed alexrififi closed 1 year ago
I found that casts does not works when you pass as the second parameter:
Nova::serving(function () {
NovaSettings::addSettingsFields([], $casts);
});
To get it works you should not use second parameter and instead write outside of the Nova::serving() function, like this:
Nova::serving(function () {
NovaSettings::addSettingsFields([]);
});
NovaSettings::addCasts(['key' => 'boolean']);
Thanks a lot!
Yeah, if we wait for the Nova::serving to run, the casts might not really be there before that event. That is the correct solution in that case.
Example of registering fields from the documentation:
If the field labels use localization, then an example would be like this:
But if localization is determined by middleware (from browser or user settings), then label localization won't work. Because the code from
\App\Providers\NovaServiceProvider::boot
will work before middleware.For the fields to become localized, you need to set the settings fields when fired
\Laravel\Nova\Events\ServingNova
event, like thisThis is not a bug, just a note 🙂