F
Filament4mo ago
essell

Action Macro to create Livewire Modals

I created a pretty nice Macro to create single Livewire Component slideover modals without the need for intermediary boiler plate (repetative) Blade views. Anything wrong with this approach? It's working nicely but I'm wondering if not returning a blade view for the modalContent presents any issues. Hopefully this is useful to someone! use Filament\Tables\Actions\Action; use Livewire\Livewire; use Illuminate\Support\HtmlString; class AdminPanelProvider extends PanelProvider { public function boot(): void { // Define a macro for the Action class Action::macro('livewireModal', function ($component) { return $this ->modalContent(function ($record) use ($component) { $htmlstring = Livewire::mount($component, ['record' => $record]); return new HtmlString($htmlstring); }) ->modalSubmitAction(false) ->modalCancelAction(false) ->modalWidth(\Filament\Support\Enums\MaxWidth::Medium) ->slideOver(); }); } }
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server