FilamentF
Filament15mo ago
nowak

How to add a CreateAction in the headerActions of resource A, to create a record in resource B?

I want to allow users to easily create a record in resource B, on the List page of resource A in its tables headerActions. I would also prefer to use the existing form from resource B as well as it's create lifecycle hooks, if possible. Basically, I want to open the existing create page of resource B in a modal by clicking an action button, which does the exact same as the existing create page does.
Is this possible?

I tried to use Filament\Actions\CreateAction on a tables headerActions just to test if this would open a create modal when clicked like this:
->headerActions([
  \Filament\Actions\CreateAction::make()
    ->model(UserOrder::class)
    ->form([
      TextInput::make('status_id')
        ->required()
        ->maxLength(255),
      // ...
    ]),
]);

But this gives this error:
Method Filament\Actions\CreateAction::table does not exist.
Was this page helpful?