custom toggle action
I'm trying to learn filament and how to extend the features. Ihave a table header where I want 3 toggle actions, and they're neither form actions or table actions, or toggle column, so I figured i needed to create a cutom action to extend the action... I have it sort of working but it's very ugly and it doesn't interact with sme of the features like requiresConfirmation. Has anyone managed to make a custom toggle action I could learn from their code? Or suggested reading?
5 Replies
Hi @justlasse Did you ever find a good solution to this? I'm looking for a toggle in the headerActions section as well.
What have you tried?. You would definitely need a custom action with a custom view since there isn’t a toggle action type.
I've never gotten my head round how to get livewire working properly for passing properties. I've been busy spamming ChatGPT and Clause, and still can't get it working 😦 I think I'm going to give up and try again tomorrow.
It’s ok to walk away when you get stuck. I’ve had to walk away from Tiptap for days at a time before.
Almost got it sorted. The livewire component is rendered via the action view() which renders a view consisting of only the livewire component (that seems inefficient, but it's the only way I know to render livewire in the view). The UI toggles, and it's internal state changes. Just need to work out how to get that state back into the action. I'll share code later today when I'm back at my pc
And got it sorted. Except the initial state isn't working quite right. Will post code here later.
OK, initial state sorted:
In header actions:
resources/views/filament/components/toggle.blade.php
app/Livewire/ToggleButton.php
resources/views/livewire/toggle-button.blade.php
I'm still convinced there are some efficiencies that could be done there, but that works
Hope that helps!