F
Filament2mo ago
Luca

Need help with updating MoneyInput

I want to get dynamically my currency. Right now i do it like this static:
MoneyInput::make('credit_limit')
->label(__('admin_panel/account.form.label.credit_limit'))
->inlineLabel()
->currency('EUR')
->columnSpan(2)
->required(),
MoneyInput::make('credit_limit')
->label(__('admin_panel/account.form.label.credit_limit'))
->inlineLabel()
->currency('EUR')
->columnSpan(2)
->required(),
Here is how I can get my Data where currency is stored:
Components\TextEntry::make('additionalData.currency')
->label('Währung')
->inlineLabel(),
Components\TextEntry::make('additionalData.currency')
->label('Währung')
->inlineLabel(),
Now my question, do you guys know how to get the Data in my Money Input as currency??
11 Replies
JJSanders
JJSanders2mo ago
Maybe by accepting a closure in the currency function?
Luca
LucaOP2mo ago
how u mean? @JJSanders
JJSanders
JJSanders2mo ago
Is thsi your own Component
Luca
LucaOP2mo ago
No its from Plugin
Dennis Koch
Dennis Koch2mo ago
Which plugin are you using?
Luca
LucaOP2mo ago
Filament
Money field by Peter Elmered - Filament
Filament field for money powered by Money PHP.
Luca
LucaOP2mo ago
Or This: Akaunting\Money
Dennis Koch
Dennis Koch2mo ago
Not sure if this is implemented correctly, but if it supports closures you could use ->currency(fn ($get) => $get('additionalData.currency'))
Luca
LucaOP2mo ago
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
Got this Error, I'm pretty new in Filament
Dennis Koch
Dennis Koch2mo ago
Yeah, I thought so. The plugin uses $this->evaluate() to early. Nothing you can change.
Luca
LucaOP2mo ago
Okay, thank you anyways

Did you find this page helpful?