F
Filament11mo ago
Anik

badge in form placeholder

Hi, I am trying to display a xfilament badge inside a form placeholder. Any idea how can i achieve something like this?
Forms\Components\Placeholder::make('kyc_status')
->label('KYC Status')
->content(new HtmlString('<div><x-filament::badge>'
. $this->record->status->getLabel() . '</x-filament::badge>
<br/>' . $this->record->status_feedback . '</div>')),
Forms\Components\Placeholder::make('kyc_status')
->label('KYC Status')
->content(new HtmlString('<div><x-filament::badge>'
. $this->record->status->getLabel() . '</x-filament::badge>
<br/>' . $this->record->status_feedback . '</div>')),
3 Replies
Anik
AnikOP11mo ago
Hi, I have somewhat achieved it with
Forms\Components\Placeholder::make('kyc_status')
->label('KYC Status')
->content(view('filament::components.badge', [
'slot' => $this->record->status->getLabel(),
'color' => $this->record->status->getColor(),
'icon' => $this->record->status->getIcon()
])),
Forms\Components\Placeholder::make('kyc_status')
->label('KYC Status')
->content(view('filament::components.badge', [
'slot' => $this->record->status->getLabel(),
'color' => $this->record->status->getColor(),
'icon' => $this->record->status->getIcon()
])),
Is there a better way to do it?
awcodes
awcodes11mo ago
HtmlString isn’t going to work like that because it doesn’t go through the blade parser. You definitely need to use a ViewField. Could possibly work with Blade::render() instead of HtmlString. But I would use the ViewField to keep it simple.

Did you find this page helpful?