F
Filament2mo ago
Gaurav

Replicate action: load form instead of save

I was searching for a way to add Clone table action, and came across Replicate action. The only difference between what I want and what this action offers is that, instead of saving the record directly, I want it to be loaded in the form instead, to be saved as a new record when Save button is clicked. Is there a way to do this with Replicate action, or is there some other action to achieve this? I'm looking for a Save As action to be precise.
Solution:
Managed via the following code: ```php Tables\Actions\CreateAction::make('Duplicate') ->label('Duplicate') ->icon('heroicon-o-document-duplicate')...
Jump to solution
1 Reply
Solution
Gaurav
Gaurav2mo ago
Managed via the following code:
Tables\Actions\CreateAction::make('Duplicate')
->label('Duplicate')
->icon('heroicon-o-document-duplicate')
->form(fn (Form $form) => static::form($form->model(static::$model))->columns(2))
->fillForm(fn ($record) => $record->toArray()),
Tables\Actions\CreateAction::make('Duplicate')
->label('Duplicate')
->icon('heroicon-o-document-duplicate')
->form(fn (Form $form) => static::form($form->model(static::$model))->columns(2))
->fillForm(fn ($record) => $record->toArray()),