activeLocale error in ListResource using Filament Spatie Translatable
I'm trying to set a translatable resource in a new v3 Filament install.
I've added the Actions\LocaleSwitcher in the getHeaderActions of the ListRecords class, but it does nothing and the browser console throws: "Livewire: [wire:model="activeLocale"] property does not exist on component"
On the edit page works perfectly
23 Replies
Did you add the Trait?
Solution
use ManageRecords\Concerns\Translatable;
maybe I'm stupid π±
You are not!
I was going crazy and I had just forget about the trait...
hahahaha, we all do that sometimes π
Do you know how I can get the active locale, to use it for example in a filter?
i'm trying to filter by a json translatable field and want to modify tthe TernaryFilter queries, but I'm not getting the active locale π¦
Hey @buzkall , sorry I had to go. Did you fix it. I think you have a parameter in the trait you can use
Try
$this->activeLocale
yes, but if I'm inside the filter query can't use $this
hmm, you can resolve
$livewire
in the callback you pass to the filter
I think
that doesn't work
and apparently I can't resolve $livewire in the true and false parameters
Can you check if you can resolve $livewire with your $query
aaah
Let me dive in the code a bit
This is in a resource right?
yes
Can you overide the table query in the ListRecords?
I'm trying to add a filter to the list
Yes, but I don't see the point in overriding the table query for a filter
I understand, yes
Can you overide it just so you add the filter
ok, but I'll have the same problem there, isn't it?
If you are in ListRecord page
it's a livewire page
and y ou will have the access to $this->activeRecord
If not, open a new ticket, maybe someone else knows, sooory π
OMG, you're a genius
yes, I can use $this->activeLocale there and the filter totally works now!
haha, thanks, maybe the solution is a bit hacky, but I cant find think of a better way
Me neither, it was driving me crazy!
Sorry for my ignorance, I got the following:
Working example π
I cant use can't use $this
GOT IT π