F
Filament16mo ago
KarlisJ

Open action modal from dropdown item

I'm probably making some silly mistake but I can't figure out how to open action modal from dropdown list blade component https://filamentphp.com/docs/3.x/support/blade-components/dropdown The example shows
<x-filament::dropdown.list.item wire:click="openDeleteModal">
Delete
</x-filament::dropdown.list.item>
<x-filament::dropdown.list.item wire:click="openDeleteModal">
Delete
</x-filament::dropdown.list.item>
But what exactly is openDeleteModal supposed to return?
10 Replies
krekas
krekas16mo ago
openDeleteModal is action in the page of whenever you use it. it's a livewire thing before using filament maybe learn basics of livewire?
KarlisJ
KarlisJOP16mo ago
I understand that it's a Livewire action. I want to understand what to de in the handler for that action to open Filament modal. Looking at the example of how block-picker.blade.php uses it for Builder component, it seems that I have to use mountFormComponentAction . I'll explore this further.
krekas
krekas16mo ago
still don't understand what dropdown has to do with a modal? in your shown example when you press on the dropdown you are trying to call livewire method when it should show values in the dropdown
KarlisJ
KarlisJOP16mo ago
still don't understand what dropdown has to do with a modal? i
In this example, there's an "Delete" item in drowdown. When clicked, I want to open confirmation modal and upon confirm perform the delete operation. To me, that action sound like "Filament action" which is not the same what "action" means in Livewire.
krekas
krekas16mo ago
requiresConfirmation()
KarlisJ
KarlisJOP16mo ago
So I have this
<x-filament::dropdown.list.item wire:click="openDeleteModal">
<x-filament::dropdown.list.item wire:click="openDeleteModal">
when clicked, Liviwire will trigger
public function openDeleteModal()
public function openDeleteModal()
What's the content of that method. Do I need to return Filament action from there?
krekas
krekas16mo ago
filament already has delete action why can't you just use that?
KarlisJ
KarlisJOP16mo ago
I'm using this as example to understand how to trigger Filament action from dropdown item I'll have dropdown with multiple items. Each item will perform some task. And for some tasks, I need to gather additional input through form. As an example, I have Action
Action::make('Do something')
->form([
Select::make('input')
->options([
// Some options
])
->required(),
])
->action(function (array $data): void {
// Do something with $data['input']
})
Action::make('Do something')
->form([
Select::make('input')
->options([
// Some options
])
->required(),
])
->action(function (array $data): void {
// Do something with $data['input']
})
and I want to trigger that from dropdown item ok, I think I have to use ActionGroup and render that instead of trying to hook actions to hardcoded blade dropdown
darcy1368
darcy13689mo ago
cccccckgbbjtbtdlchltckhfiedrnuhuifeenbijckbk
Want results from more Discord servers?
Add your server