Load action modal in different livewire component
Hi there!
I was wondering if there is a way to load a action modal/slide-over in a different livewire component than what it was created in.
I am looking at needing this as the app layout is based on normal blade templates, and z indexes and stuff interfer and makes the slide overs and modal render "inside" the space for the component which called it, not the whole page (which is wanted behaviour).
Any way to do this? Tried having a read at the docs, but my brain is completely fried...
Solution:Jump to solution
Well... yeah it's not as simple as a Filament action, but I think in this example the Livewire component would contain both the modal and the form, something like this:
```html
<div id="custom-livewire-component">
<x-filament::modal id="custom-form">
<form wire:submit="create">...
19 Replies
Quick mockup of wanted behaviour:
Additional info is that only livewire used here is inside the square in the middle, rest is "normal" blade
Am I reading this correctly: You have a custom table in an area of your page, the table displays correctly but the action modals coming from the table are not? You would like the modals to be mounted towards the end of your DOM instead?
You are Reading it 100% correct 🙂
Cool, and is this a row action or a header action? What does the action do actually? (just out of curiosity)
Row action 🙂 It should trigger a edit form simply.
Code:
The structure looks something like this:
And on the last one there the filament stuff is loaded and livewire first utilized
Code for that file so you have an idea:
Ok, very cool! So first, I'm not sure I have the best solution... maybe someone will correct me. But I think I have an idea.
Rockin! Cause i have nonen hah, tried a few creative ways but have got none working
Do you already have a
@yield
in your Blade where the modal should go ideally?Nope, but thats quick to add
Yep, and I presume you're comfortable with Livewire events?
Familiar with those yep 🙂 Have thought about that route, but have not quiiiteee seen how it could be hooked in "properly"
First time filament user, coming from Nova so familiar land but quite unfamiliar at same time
Ok so here's my idea: Add a
@yield
at the appropriate place in your page layout. Then, create a custom Livewire component that will be your custom modal and form (hidden by default). Then, from your table action, dispatch an event to open the custom modal, and pass the $record->id
from the row so that the form can load and save to the appropriate place.
Let me know if this sounds unclear, I think I can point you to some useful parts of the docs.Hmm, i see the way you are thinking.
So potentially then inside there load up a filament form?
And for the modal/slide-over itself utilize this component? https://filamentphp.com/docs/3.x/support/blade-components/modal
How would i then pass to the livewire component hmm?
Or do i then need to "scratch" the filament stuff and "DIY" it you think?
Solution
Well... yeah it's not as simple as a Filament action, but I think in this example the Livewire component would contain both the modal and the form, something like this:
Another option possibly is to render just a Filament form with an independant action in it, then trigger this action from the table action.
Hmm, from that i got an idea which i am starting to think: why did i not just to that: I can potentially just do a full page livewire component
Wow