F
Filament16mo ago
KA

Displaying a description with HTML tag or entity on TextColumn

is there any way to add html entity or tag inside ->description() on a table row? i have tried as following: Tables\Columns\TextColumn::make('status') ->description(fn (Tracking $record): string => \Carbon\Carbon::parse($record->date)->since() . ' ⋅ ' . $record->port->name)
Solution:
Jump to solution
7 Replies
Dan Harrin
Dan Harrin16mo ago
in this case, do you really need the html can you not just use the encoded version
Solution
Dan Harrin
Dan Harrin16mo ago
Dan Harrin
Dan Harrin16mo ago
if you're sure, wrap it in new HtmlString() but its really unnessecary also be aware that you will open yourself up to XSS, so trust the port name
KA
KAOP16mo ago
i used the ⋅ (encoded version), just was curious to learn. Anyway, thanks for your suggestion about XSS. I am convinced to avoid to use HTML.
Phuc Le
Phuc Le14mo ago
@Dan Harrin @KA Does v3 remove the html support in description method? This is my code, it renders html as text:
TextColumn::make('source')
->label('Source/Mode')
->formatStateUsing(fn(KeywordFinderSource $state): string => $state->headline())
->description(fn(KeywordReport $record): ?string => new HtmlString('<p class="text-2xl">' . $record->mode . '</p>'))
->html(),
TextColumn::make('source')
->label('Source/Mode')
->formatStateUsing(fn(KeywordFinderSource $state): string => $state->headline())
->description(fn(KeywordReport $record): ?string => new HtmlString('<p class="text-2xl">' . $record->mode . '</p>'))
->html(),
Dan Harrin
Dan Harrin14mo ago
your return type is wrong. and please dont @ me #✅┊rules
Phuc Le
Phuc Le14mo ago
thank you, that works. Sorry for @ you, I didn't know that.
Want results from more Discord servers?
Add your server