F
Filament12mo ago
Tieme

static values Table / Infolist/ DateTimePicker based on locale

Hi All, There are some static values in the Table / Infolist/ DateTimePicker class. If i set them in AppServiceProvider the values change with my options. Example settings
Infolists\Infolist::$defaultCurrency = $options['defaultCurrency'];
Infolists\Infolist::$defaultDateDisplayFormat = $options['defaultDateDisplayFormat'];
Infolists\Infolist::$defaultDateTimeDisplayFormat = $options['defaultDateTimeDisplayFormat'];
Infolists\Infolist::$defaultTimeDisplayFormat = $options['defaultTimeDisplayFormat'];
Infolists\Infolist::$defaultCurrency = $options['defaultCurrency'];
Infolists\Infolist::$defaultDateDisplayFormat = $options['defaultDateDisplayFormat'];
Infolists\Infolist::$defaultDateTimeDisplayFormat = $options['defaultDateTimeDisplayFormat'];
Infolists\Infolist::$defaultTimeDisplayFormat = $options['defaultTimeDisplayFormat'];
I want to change these values based on current locale from user. I use this plugin to add local to dashboard. https://filamentphp.com/plugins/bezhansalleh-language-switch I created a Middleware to set these settings. In the Middleware i have the correct locale. Now the problem is that these values are not set, and only the default in the classes are set. This is my complete Middleware : https://gist.github.com/sitenzo/4b357ab20284e1bf79bd3e5eef994036 How can i set these values based on locale? Thanks
Filament
Language Switch by Bezhan Salleh - Filament
Zero config Language Switcher plugin for Filament Panels.
Gist
FilamentLocaleOptions.php
GitHub Gist: instantly share code, notes, and snippets.
Solution:
I now know what the problem is. In my AppServiceProvider is set some settings for table but not locale because it is always the local of the app and not user. the static settings for table is set in a Middleware. ...
Jump to solution
4 Replies
Tieme
TiemeOP12mo ago
Anyone?
awcodes
awcodes12mo ago
Setting them like that won’t work. Follow https://filamentphp.com/docs/3.x/forms/fields/getting-started#global-settings And in the callbacks you can get the locale with app()->getLocale() to see what it is and configure the fields appropriately.
Solution
Tieme
Tieme12mo ago
I now know what the problem is. In my AppServiceProvider is set some settings for table but not locale because it is always the local of the app and not user. the static settings for table is set in a Middleware. i cant configure the table twice, than it will use the AppServiceProvider and not the Middleware. To get this working i need to set all table settings in the Middleware
Tieme
TiemeOP12mo ago
@awcodes I created a issue, it is not working as expected in documentation https://github.com/filamentphp/filament/issues/10459
GitHub
Global Settings in Middelware not working correctly · Issue #10459 ...
Package filament/filament Package Version 3.1.27 Laravel Version 10.38.2 Livewire Version No response PHP Version 8.1.6 Problem description In my project i use different locales, there are some sta...
Want results from more Discord servers?
Add your server