F
Filament2y ago
Remi

Render Single Table action on different place

My table has multiple TableHeaderActions. 1 want all of them on the place they render by default, except one. Which i want to render elsewhere. So far i found
{!! Action::make('action')->requiresConfirmation()->action(fn() => dd('action works'))->toHtml() !!}
{!! Action::make('action')->requiresConfirmation()->action(fn() => dd('action works'))->toHtml() !!}
It renders the button where i want, but it doesnt work. Only when i add this button to the tableHeaderActions as well, it works. But then it is rendered in both places. It's like the modal doesnt render like this. I tried to
@include(Action::make('action')->requiresConfirmation()->action(fn() => dd('action works'))->getView())
@include(Action::make('action')->requiresConfirmation()->action(fn() => dd('action works'))->getView())
But that gives me errors about the $action variable not being set. I get that the button i render has wire:click="mountTableAction('action')" and its not in de table action array. So is there a way to include it in the tableaction array, but not have it render with the rest? Question: How do i render 1 tableHeaderAction in a different place from the rest?
2 Replies
Remi
RemiOP2y ago
Update: i sort of got it working, but it feels quite hacky: i added the Action to the getTableHeaderActions array, and added ->view('custom-view') this custom-view is an empty blade file. This way it doenst render anything in the headeractions. Then i added the blade directive to render the html on the new position. Would be nice if i could just do ->hidden() in the tableHeaderActions and the modal would still work when triggering from another button. Or a new callback like ->invisible() Or am i missing a completely obvious better way?
Dan Harrin
Dan Harrin2y ago
if the action isnt registered its not gonna work because we cant just guess what logic to run when the button is pressed in v3 actions can be added anywhere on a livewire component. thats what you'd need
Want results from more Discord servers?
Add your server