Call custom function after Toggle button changed (Outside Form)

What I want to achieve: I'm trying to achieve a specific functionality with the toggle button which is on each member entry in my member list. The toggle is on the item itself and not inside the edit form. I want to call a custom function after the toggle is disabled again from an truthly state (enabled state). What I did so far: I tested the afterSave() hook in my EditMember.php file. Where am I stuck Since this afterSave hook is only called when I edit my member model within the form, the custom function within the afterSave hook is not getting called. Thanks for your feedback guys.
No description
6 Replies
Bene Richi
Bene RichiOP14mo ago
Hmmm.. I tried to add the "afterStateUpdated" hook to my ToggleColumn, following the instructions in the docs. But it turns out, ToggleColumn doesn't even have that function. Method Filament\Tables\Columns\ToggleColumn::afterStateUpdated does not exist.
ToggleColumn::make('is_abo_stop')
->afterStateUpdated(fn ($state, callable $set) => $set(dd($state)))
->label('Abo Stop')
->onIcon('heroicon-m-stop')
->offIcon('heroicon-m-check')
->onColor('warning'),
ToggleColumn::make('is_abo_stop')
->afterStateUpdated(fn ($state, callable $set) => $set(dd($state)))
->label('Abo Stop')
->onIcon('heroicon-m-stop')
->offIcon('heroicon-m-check')
->onColor('warning'),
Bene Richi
Bene RichiOP14mo ago
No description
krekas
krekas14mo ago
open issue on github then
Lara Zeus
Lara Zeus14mo ago
it dose exist I guess you're on older version!?
No description
Bene Richi
Bene RichiOP14mo ago
Yes solve now by composer upgrade. I was already on FilamentPhp v3.0. DId not expect that this hook was introduced later. Thank you all !

Did you find this page helpful?