passing custom color
So i have something like this:
ViewColumn::make('status')
->getStateUsing(function ($record) {
$status = ContractStatusEnum::tryFrom($record->status);
if ($status) {
return [
'label' => $status->getLabel(),
'color' => Color::hex($status->getColor()),
'icon' => $status->getIcon(),
];
}
return [
'label' => '-',
'color' => null,
'icon' => null,
];
})
->view('filament.forms.components.contract-status-field'),
And custom view:
{{ $getState()['label'] }} <x-filament::icon-button
icon="{{$getState()['icon']}}"
color="{{ $getState()['color'] }}"
/>
now the issue is, the color is hex, when i convert it and try to use with getState[color] i get the following error htmlspecialchars(): Argument #1 ($string) must be of type string, array given, i've tried unsafe render in laravel but still, am i missing something?1 Reply
The button is expecting a color key like ‘primary’ and in your column, using Color::hex() converts the hex to an array of tailwind shades. If you want to use the button like that you’ll need to register the color with filament.