Reset custom table header action modal form

Hi, I have a table header action with a form on a modal that works great. I recently wanted to add a "add and create another" submit button to the modal since I found myself saving and adding again alot.

This is my table header action button placed in the ->headerActions() of the table.

I followed the instructions on how to add button, but how can I reset the form? You can see in the action that I tried many options, but none are working.

Tables\Actions\Action::make("add")
    ->label("Add Segment")
    ->icon("heroicon-m-plus")
    ->modalSubmitActionLabel("Save")
    ->extraModalFooterActions(fn (Tables\Actions\Action $action): array => [
        $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
            ->label("Save and add another"),
    ])
    ->closeModalByClickingAway(false)
    ->form(SegmentForm::getForm())
    ->action(function(array $data, array $arguments, Tables\Actions\Action $action, Forms\Set $set){

        // .. The action

        if($arguments['another'] ?? false){

            // How to reset the form?
            // Have tried these combinations
            $action->resetFormData();

            // Tried with an empty array and with all the fields with "empty" states
            $action->formData([
                "type" => "" // also tried null
            ]);
            $action->fillForm([
                "type" => "" // also tried null
            ]);

            // Also tried $set
            $set("type", null);



            // Stopping the modal from closing
            $action->halt();
        }
    }),
`

Anyone experienced this and have solved it? πŸ™‚

Thank you for your help!
Solution
Inject Form $form and use $form->fill();
Was this page helpful?