Unable to add form actions to modal

Hi, I've got a resource with a simple form for creating / editing. I've got a table that displays all the items on the index. Each row in the table has an edit button that opens the edit page in a modal slideover. At the bottom there is a "Save changes" and "Cancel" button. I'd like to add an additional button to the bottom, but I'm unable to get it to show. I added the below to my EditItem.php in the Resource Pages directory and the button didn't show.
protected function getFormActions(): array
{
return [
...parent::getFormActions(),
Action::make('foo')->action('bar'),
];
}
protected function getFormActions(): array
{
return [
...parent::getFormActions(),
Action::make('foo')->action('bar'),
];
}
I also tried getModalActions which made no difference. If I change the page to be a separate page rather than a modal, the button does appear - but that's not what I want. I'm at a loss, so any ideas welcome. Thanks
3 Replies
Adam Holmes
Adam Holmes3mo ago
Thanks for the pointer in the right direction. I'm having trouble working out where to put this block though. Should it be on my table action?
public static function table(Table $table): Table
{
return $table
--- SNIP ---
->actions([
Tables\Actions\EditAction::make()
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]),
]),
])
--- SNIP ---
]);
}
public static function table(Table $table): Table
{
return $table
--- SNIP ---
->actions([
Tables\Actions\EditAction::make()
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]),
]),
])
--- SNIP ---
]);
}
When I do that the type is wrong...
App\Filament\Resources\ListItemResource::App\Filament\Resources\{closure}(): Argument #1 ($action) must be of type Filament\Actions\Modal\Actions\Action, Filament\Tables\Actions\EditAction given, called in /var/www/html/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
App\Filament\Resources\ListItemResource::App\Filament\Resources\{closure}(): Argument #1 ($action) must be of type Filament\Actions\Modal\Actions\Action, Filament\Tables\Actions\EditAction given, called in /var/www/html/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
I can't think where else it should be as the modals are generated using slideOver and so I've not had to create any actions etc, it's all just worked "out the box" Thanks Ahhh - looks like I just needed to namespace the table action. Thanks!
mrvn
mrvn2mo ago
I am trying to achieve almost the same but is there a way to add a simple action button to the modal which excecutes some code without confirming or canceling the modal itself? I would just have a button which triggers an api call but ->action(() => ...) is not fired but using ->url(...) does:
TextInput::make('report_url'),
Actions::make([
Action::make('record')
->modalContent(function (Get $get) {
return view('iframe', ['url' => $get('remote_url')]);
})
->extraModalFooterActions(function (Get $get) {
$url = $get('report_url');
return [
ActionsAction::make('report')->action(fn () => dump('hi'))
];
})
->slideOver()
->mountUsing(function (Set $set, Get $get) {
$url = $get('settings.scope.url');
})
->modalCancelAction(function (Get $get) {
Http::get($get('url'));
})
->action(function (Set $set, Get $get) {
Http::get($get('test_url'));
})
])
TextInput::make('report_url'),
Actions::make([
Action::make('record')
->modalContent(function (Get $get) {
return view('iframe', ['url' => $get('remote_url')]);
})
->extraModalFooterActions(function (Get $get) {
$url = $get('report_url');
return [
ActionsAction::make('report')->action(fn () => dump('hi'))
];
})
->slideOver()
->mountUsing(function (Set $set, Get $get) {
$url = $get('settings.scope.url');
})
->modalCancelAction(function (Get $get) {
Http::get($get('url'));
})
->action(function (Set $set, Get $get) {
Http::get($get('test_url'));
})
])
Want results from more Discord servers?
Add your server
More Posts
Is it possible to adjust the navigation panel width to be even smaller?I already sent the width of the content to the maximum possible option but there's still so much wasFilament 3 - Multi Tenancy Upload Image ErrorI encountered this error: Unable to retrieve the file_size for file at location: livewire-tmp/GfJyK6Updating Standalone Action's modal description based on the argument passed to the formI have a standalone action that launches a modal. I want to update the modal description based on thSpark Billable Slug redirects to wrong urlI am using the Spark Billing Portal with Filament and everything is working so far, except the rediIs it possible to pre-populate this form with some data?I have a custom widget, with a heading defined like so: ```php <div class="flex items-center justifTrouble with Export/Import in Laravel Filament Admin Panel: 'Login Route Not Found' ErrorHi, I'm currently using the Laravel Filament admin panel for my application. I've been working on geHow can personalize the buttons style for Create, Delete, Cancel, SaveHey guys, i working and configuring a new theme in my project, i inspect the desing and can see the Getting Error in Sudden Change in TabI'm using a Custom table which is changing through a Year filter and I 'm getting Typed property FilHow do I filter data by permissionI have a table of Orders. So i have OrderResource but how do i filter the order based on type. For open modal on page loadI have a modal that has a trigger button and opens fine from the trigger button, but I also want to