Htmlable label - illegal offset type
Hello, everyone.
I'm having a little problem with label(). My goal would be to replace the label text with a small image (a google logo).
The problem is that when I try to use a new HtmlString as the label value, it returns an error like ‘Illegal offset type’ no matter what I enter.
As soon as I enter a normal string instead, everything is fine.
I also found this example online:
but I can't figure out what the problem is. Is it possible that it does work only on Forms?
Thank you all very much for your support 😄
Solution:Jump to solution
@Dennis Koch I solved the problem:
in
AppServiceProvider
I created this function:
```
protected static function translateLabel(Field|Column $element): string...5 Replies
This works for me:
Can you share the error (via Flare) for more infos?
And the actual code you are using?
Hi Dennis, thanks for replying.
I don't have a Flare account sadly, I attached a screenshot of the error.
Here's the code of the column:
It's pretty much standard.
This is a Livewire component which has Filament forms & table. Everything works has a charm, except this.
You return a view as the state. I think that’s the issue. State is a value
Ok, I'll look into that 🤔 thank you Dennis!
Sadly, also with this kind of code:
It returns the same error. I'm working on already-done code, so I'm trying to understand what's happening 😅
@Dennis Koch could it be that I have this in the
AppServiceProvider
?
EDIT:
Yes, I commented the code above and now it works without problems, but I really need the labels to be automatically translated without me writing it 😅Solution
@Dennis Koch I solved the problem:
in
AppServiceProvider
I created this function:
and then:
For now it's working 😄 thanks for your input!