FilamentF
Filament14mo ago
2 replies
TranceCode

How can show jason to html?

i need show the message of notification like html but it's not working, i have this code

public static function infolist(Infolist $infolist): Infolist
    {
        return $infolist
            ->schema([
                TextEntry::make('id'),
                TextEntry::make('type'),
                TextEntry::make('data')
                    ->label('Detalles')
                    ->formatStateUsing(function ($state) {
                        $decodedData = json_decode($state, true);

                        if (json_last_error() !== JSON_ERROR_NONE) {
                            return 'Error al decodificar los datos.';
                        }

                        // Construir un texto legible para la columna
                        $body = $decodedData['body'] ?? 'Sin descripción.';
                        $actions = $decodedData['actions'] ?? [];
                        $formattedActions = '';

                        foreach ($actions as $action) {
                            $formattedActions .= "- {$action['label']} ({$action['url']})\n";
                        }

                        return "Descripción: {$body}\nAcciones:\n{$formattedActions}";
                    }),
            ]);
    }

i try with
->html()
but not working

Any recommendation or idea for fix this problem?
image.png
Was this page helpful?