Load component into Action modal?
Hey! Can a component be passed to an action instead of a view?
6 Replies
Pretty sure that’s a no.
You can use a form in an action though without a view.
But you can’t pass blade components
What would this look like though, would you pass the class name of your Blade component? What about the props?
I wanted to load a Livewire component instead of a blade view in a modal that is opened through the action. Something like this:
ViewAction::make()->modal()->component(LivewireComponent::class)
Oooh a Livewire component. Yeah, I think you need to wrap it in a Blade view...
The problem there would be that you can’t instantiate a LW component. It has to be rendered by blade.
And if it tries to render too early it will just throw an exception.
Ok, I understand. But it feels wrong to use a blade file just to load an LW component. Couldn't we solve this more elegantly by using a kind of placeholder blade template specifically designed for such cases, so that we don't need an additional blade file for every LW component we want to open in a modal?