Skip View Step

Hi all I have the below action code on my filament page. It will open a modal which in turn opens a livewire component with a filament table on it.
public function postTaxAdjustmentsAction(): Action
{
return Action::make('postTaxAdjustmentsAction')
...
->modalContent(view('livewire.budget.adjustments'));
}
public function postTaxAdjustmentsAction(): Action
{
return Action::make('postTaxAdjustmentsAction')
...
->modalContent(view('livewire.budget.adjustments'));
}
The above opens
<livewire:budget.list-post-tax-adjustements lazy="on_load" />
<livewire:budget.list-post-tax-adjustements lazy="on_load" />
. Can I skip a step and simply call the livewire component from within the Action code ?
8 Replies
toeknee
toeknee3w ago
Try:
->modalContent(fn (): string => Blade::render('@livewire(\'livewire.budget.adjustments\')'),
->modalContent(fn (): string => Blade::render('@livewire(\'livewire.budget.adjustments\')'),
David | Fortune Validator
Thank you,. I just came across this as well:

->modalContent(fn()=> Livewire::component('budget.net-adjustments'))
or
->modalContent(fn()=> Livewire::mount('budget.net-adjustments'))

->modalContent(fn()=> Livewire::component('budget.net-adjustments'))
or
->modalContent(fn()=> Livewire::mount('budget.net-adjustments'))
Do you think there is a best way of doing this out of the three options?
toeknee
toeknee3w ago
The above is good
David | Fortune Validator
hmm, im getting Filament\Actions\MountableAction::getModalContent(): Return value must be of type Illuminate\Contracts\View\View|Illuminate\Contracts\Support\Htmlable|null, string returned on your Blade version looks like it needed :
->modalContent(fn () => new HtmlString(Blade::render('@livewire("budget.list-post-tax-adjustements")')))
->modalContent(fn () => new HtmlString(Blade::render('@livewire("budget.list-post-tax-adjustements")')))
HtmlString
toeknee
toeknee3w ago
Yep that should do it, my version was just freehanded memory
David | Fortune Validator
no problem. Much appreciated on a random pointer. I did notice the use of =lazy="on_load" is needed on the component call, otherwise the first click on the modal is ignored for some reason actually slightly nicer ways seems to have #[Lazy(isolate: true)] on the livewire component itself sorry to hassle you again but I wanted your advice if I may:
->modalContent(fn (RelationManager $livewire) => new HtmlString(
Blade::render('@livewire("estimates.actions.pdq.import-price", ["estimate" => $estimate])', [
'estimate' => $livewire->getOwnerRecord()
])
))
->modalContent(fn (RelationManager $livewire) => new HtmlString(
Blade::render('@livewire("estimates.actions.pdq.import-price", ["estimate" => $estimate])', [
'estimate' => $livewire->getOwnerRecord()
])
))
I want to pass some data to the mount of the livewire component. would the above be the right way. It does work but again I want to make sure im doing things the right way
toeknee
toeknee3w ago
That looks right
David | Fortune Validator
thank you

Did you find this page helpful?