is it possible to have ToggleColumn with text in filament v2?
Hello all,
In my form I have toggle field is_submitted like this and it works absolutely fine.
Toggle::make('is_submitted')->label('Change here')->inline(false)->default(false)->reactive()
->afterStateUpdated(function ($state, $set){}) ->onColor('success')
->offColor('danger'),
Placeholder::make('status')->label('Currently')->content(function ($state, $get) {
$status = $get('is_submitted') === true ? 'Submitted' : 'Not Submitted';
$style = $status === 'Submitted' ? 'color: green;' : 'color: red;';
return new HtmlString("<span style='" . $style . "'>" . $status . "</span>");
})->extraAttributes(['class' => 'text-primary-500 mt-15 items-center font-bold text-xs']),
and this is the ToggleColumn in the table
ToggleColumn::make('is_submitted')->label('Status')->onColor('success')
->offColor('danger'),
I want to give the same text like 'Submitted' or 'Not Submitted' in the ToggleColumn of my table, is this acheiveable?6 Replies
please read the #✅┊rules on code formatting
Can you provide a screenshot of what you have
Thank you so much for your reply @toeknee . I apologize for the code formatting issue.
I managed to get the desired functionality with the following code:
and the result is as shown in the image
I've suggested to use
formatStateUsing
instead of default
. Ref: https://filamentphp.com/docs/3.x/tables/columns/text#custom-formattingGreat! that works well, thank you so much @Vp .
hey VP do you have any idea why I'm getting this error while tyring to use Dennis Excel Pluging
composer require pxlrbt/filament-excel
Error
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
by the way, I'm using filament V2.Is there any failed exact reason? otherwise don't know
sorry, it was my mistake. I need to enable the zip extension in php --ini and did that. I think it should work now, thanks though.