F
Filament2mo ago
Prodex

ExtraModalFooterAction does nothing

Hi, I'm trying to render an extra action for the editOptionModal:
->editOptionAction(fn (Forms\Components\Actions\Action $action) => $action->extraModalFooterActions(fn (Action $action): array => [
\Filament\Actions\Action::make('something')
->icon('heroicon-o-trash')
->action(fn ($record) => dump($record)),
]))
->editOptionAction(fn (Forms\Components\Actions\Action $action) => $action->extraModalFooterActions(fn (Action $action): array => [
\Filament\Actions\Action::make('something')
->icon('heroicon-o-trash')
->action(fn ($record) => dump($record)),
]))
The button renders as it should, but when I click it, nothing happens. No php or js errors as well. How can I fix that? Thanks!
5 Replies
Rolland
Rolland2mo ago
from my experience you need to write/assign the extra action to a boolean variable and then set the variable in the ->action(). example:
->action(function () {

if($variable === true) {
// run the extra action logic
} else {
// run the default action logic
})
->extraModalFooterActions(fn () => $variable = true);
->action(function () {

if($variable === true) {
// run the extra action logic
} else {
// run the default action logic
})
->extraModalFooterActions(fn () => $variable = true);
toeknee
toeknee2mo ago
dump wouldn't work, you want dd() that would throw an exception then.
Prodex
ProdexOP2mo ago
How would you implement this kind of feature to delete records in edit modal?
toeknee
toeknee2mo ago
dd = dump die; youm would just do $record->delete() ? send ntoification : failed notification
Prodex
ProdexOP2mo ago
sorry, my example didn't cover this: What I wanted to achieve is a delete button in the footer of the edit modal. I've already tried ->action(fn ($record) => $record->delete()) which didn't do anything.
Want results from more Discord servers?
Add your server