mutateFormDataBeforeCreate not running on create from Relation Manager

I have a Filament resource and in its Create page I implemented the mutateFormDataBeforeCreate method to populate the user_id from the auth object. Ex:

$data['user_id'] = auth()->id();

It works well and gets populated on Resource create. However, I also have a RelationManager on a related Model for this same Resource and when I click the create action and complete the form the user_id is missing and the create fails because its a required field in the db.

Why is that? Am I missing something?
Solution
One way would be to mutate the data on the relation managers CreateAction?

Tables\Actions\CreateAction::make()
  ->mutateFormDataUsing(function (array $data) {
      $data['user_id'] = auth()->id();
      return $data;
  })


🤔
Was this page helpful?