Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

themenace's avatar

Filament -

Can anyone please give me a clue how to achieve this in filament ? {!! html_entity_decode($order->title) !!} Thanks

0 likes
2 replies
LaryAI's avatar
Level 58

It seems like you're asking how to render HTML content in a Filament admin panel, specifically using the html_entity_decode function in a Blade view. Filament uses Blade components extensively, so you can achieve this by creating a custom column or field that renders HTML content safely.

Here's a basic example of how you might set this up in a Filament resource:

  1. Create a Custom Column for Displaying HTML Content

    You can create a custom column in your Filament resource that uses Blade to render the HTML content. Here's how you might define this column in your resource's getTableColumns() method:

use Filament\Tables;
use Filament\Tables\Columns\TextColumn;

class OrderResource extends Tables\Table
{
    protected function getTableColumns(): array
    {
        return [
            TextColumn::make('title')
                ->html()
                ->formatStateUsing(function ($state) {
                    return html_entity_decode($state);
                }),
        ];
    }
}

In this example, the TextColumn is used with the html() method to indicate that the column may contain HTML. The formatStateUsing method is used to decode the HTML entities.

  1. Ensure Safe Content Rendering

    When rendering HTML content directly from the database, it's crucial to ensure that this content is safe to prevent XSS (Cross-Site Scripting) attacks. Make sure that any user-provided content that might be rendered as HTML is properly sanitized before saving it to the database.

  2. Using the Custom Column in Filament

    Once you have defined your custom column, it will automatically be used in the Filament admin panel for the Order resource. You don't need to make any additional changes to view the decoded HTML in the admin panel.

This approach keeps your application secure while allowing certain HTML content to be rendered in the Filament admin panel. Always be cautious with HTML content and ensure it's from a trusted source or sanitized appropriately.

Please or to participate in this conversation.