F
Filament6mo ago
Daniel

Remove Buttons in Action Modal

Hey guys! I am using a suffixAction for a Select component im Filament form that opens a modal. I would like to remove the buttons at the bottom of the modal so that I just have the label "Action needed" the modal content "Test123" and the close button in the top right corner. How can I remove/hide the buttons?
->suffixAction(function ($record, $get, $set) {
$actionLabel = $record->course_status === Course::STATUS_ACTIVE ? 'Deactivate' : 'Activate';
$actionIcon = $record->course_status === Course::STATUS_ACTIVE ? 'heroicon-o-x-circle' : 'heroicon-o-check-circle';
$actionColor = $record->course_status === Course::STATUS_ACTIVE ? 'danger' : 'success';

// if no product is set, instead show a button, that opens a modal to select a product
if(!$record->product_id) { <--- This is the important part
return Forms\Components\Actions\Action::make('advance')
->label('Action needed')
->icon('heroicon-o-shield-exclamation')
->color('danger')
->modalContent(view('filament.advance'))
->modalContentFooter()
->modalCloseButton();
}

return Forms\Components\Actions\Action::make('toggleStatus')
->label($actionLabel)
->icon($actionIcon)
->color($actionColor)
->requiresConfirmation()
->action(function ($record) use ($set) {
logger('Toggling status');
$record->course_status = $record->course_status === Course::STATUS_ACTIVE ? Course::STATUS_INACTIVE : Course::STATUS_ACTIVE;
$record->save();
$set('course_status', $record->course_status);
});
})
->suffixAction(function ($record, $get, $set) {
$actionLabel = $record->course_status === Course::STATUS_ACTIVE ? 'Deactivate' : 'Activate';
$actionIcon = $record->course_status === Course::STATUS_ACTIVE ? 'heroicon-o-x-circle' : 'heroicon-o-check-circle';
$actionColor = $record->course_status === Course::STATUS_ACTIVE ? 'danger' : 'success';

// if no product is set, instead show a button, that opens a modal to select a product
if(!$record->product_id) { <--- This is the important part
return Forms\Components\Actions\Action::make('advance')
->label('Action needed')
->icon('heroicon-o-shield-exclamation')
->color('danger')
->modalContent(view('filament.advance'))
->modalContentFooter()
->modalCloseButton();
}

return Forms\Components\Actions\Action::make('toggleStatus')
->label($actionLabel)
->icon($actionIcon)
->color($actionColor)
->requiresConfirmation()
->action(function ($record) use ($set) {
logger('Toggling status');
$record->course_status = $record->course_status === Course::STATUS_ACTIVE ? Course::STATUS_INACTIVE : Course::STATUS_ACTIVE;
$record->save();
$set('course_status', $record->course_status);
});
})
No description
2 Replies
Want results from more Discord servers?
Add your server