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?
No description
No description
6 Replies
toeknee
toeknee9mo ago
please read the #✅┊rules on code formatting Can you provide a screenshot of what you have
leoPascal
leoPascal9mo ago
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:
ToggleColumn::make('is_submitted')->label('Update')->onColor('success')
->offColor('danger'),

TextColumn::make('status')
->label('Status')
->default(function ($record) {
return $record->is_submitted ? 'Submitted' : 'Not Submitted';
})
ToggleColumn::make('is_submitted')->label('Update')->onColor('success')
->offColor('danger'),

TextColumn::make('status')
->label('Status')
->default(function ($record) {
return $record->is_submitted ? 'Submitted' : 'Not Submitted';
})
and the result is as shown in the image
No description
Vp
Vp9mo ago
leoPascal
leoPascal9mo ago
Great! 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.
Vp
Vp9mo ago
Is there any failed exact reason? otherwise don't know
leoPascal
leoPascal9mo ago
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.
Want results from more Discord servers?
Add your server
More Posts