FilamentF
Filament11mo ago
2 replies
fk

How to keep a modal open after submitting

in a resource list page
i create a button that user can input a form and submit.
my goal: when submitted i want the modal to stay open so user can submit another one.

what i did
i disable the default "submit" button and create another one.
created a custom submit button (https://filamentphp.com/docs/3.x/actions/modals#adding-an-extra-modal-action-button-to-the-footer)
i also added $this->form->fill(); in my action (https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#resetting-a-forms-data)
but i got error ( Filament\Resources\Pages\ListRecords::form(): Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given, called in /var/www/html/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 55 )

can anyone help me with this?


Action::make('create')
    ->form([
        // ...
    ])
    // ...
    ->modalSubmitAction(false)
    ->extraModalFooterActions(fn (Action $action): array => [
        $action->makeModalSubmitAction('createAnother', arguments: ['another' => true]),
    ])
    ->action(function (array $data, array $arguments): void {
        // Create
 
        if ($arguments['another'] ?? false) {
            // Reset the form and don't close the modal

// here
             $this->form->fill();


        }
    })
Was this page helpful?