Create Action that opens a modal in a custom Livewire Component
Is it possible to create actions that opens a modal in a custom livewire component inside a filament custom page, if it is possible. What are the steps?
11 Replies
here is my livewire component named Folder
Class
view
What is not working
the modal is not opening
Did you check this section? https://filamentphp.com/docs/2.x/admin/pages/actions
Filament
Actions - Pages - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.
Is this a livewire component or custom page?
yup but ive got this error
Typed property Filament\Pages\Actions\Action::$livewire must not be accessed before initialization
class Folder extends Component
{
public $folder;
public function mount(FolderModel $folder)
{
$this->folder = $folder;
}
public function render()
{
return view('filament.components.livewire.asset-management.folder');
}
public function getActions(): array
{
return [
Actions\ActionGroup::make([
Actions\Action::make('delete')
->action('deleteFolder')
->requiresConfirmation()
])->color('secondary'),
];
}
public function deleteFolder(){
dd("DELETED");
}
}
livewire component
Your page should wrap in <x-filament::page>
yep i wrap it, heres my custom page
This is because the your custom component is not setup for filament action
There are ways to make it works but might be too complicated to test
okay thanks
in v3 you can attach actions to custom lw components