-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for dynamically updating currency and locale of MoneyInput #42
Comments
Thank you for the report! I will investigate this today. |
I don't believe this error has anything to with this plugin. It is how Filament works. I think you have to do something like this:
|
I have now tested some, and I'm not sure how well it works to change the field dynamically like this. This is something I will have to look into in the future. For now I would probably just use a currency select and a normal input without localized format. For displaying it should work with the If you find a way to support this, please let me know. |
I think this issue will be addressed if we figure out how prices should be persisted. My view of s Is there a recommended way? Especially if there are multiple prices in record. |
Yes, I would agree with that! I guess the best way to do this is a integer/decimal column for amount and one char(3) for currency. We should add a migration type for this like for example the morph type that created two related columns. |
Describe the bug
I'm encountering an error when trying to dynamically set the currency and locale for the
MoneyInput
component in Filament forms. The error occurs specifically when trying to use a closure for thecurrency
property.Error Message
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
The error is triggered by this line:
Changes have in global config:
// .env file settings
MONEY_DEFAULT_LOCALE=es_PE
MONEY_DEFAULT_CURRENCY=PEN
// Configuration published with
php artisan vendor:publish --provider="Pelmered\FilamentMoneyField\FilamentMoneyFieldServiceProvider" --tag="config"
Expected behavior and actual behavior
I expected the MoneyInput component to correctly use the dynamically set currency and locale values without causing initialization errors. Instead, it throws an error indicating that the property $container must not be accessed before initialization.
Screenshots
Additional context
I believe the issue might be related to the initialization of the $container property, which seems to be accessed before it is fully initialized. Any insights or solutions to this problem would be greatly appreciated. Thank you for your assistance!
Version of:
This package: Latest
Filament: 3.2
PHP: 8.2
Laravel: 10.10
The text was updated successfully, but these errors were encountered: