© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
5 replies
andeancondor_74

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


🤔
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

mutateFormDataBeforeCreate not being called on create
FilamentFFilament / ❓┊help
3mo ago
Create action with relation manager
FilamentFFilament / ❓┊help
7mo ago
Customizing relation manager create behavior
FilamentFFilament / ❓┊help
2y ago
Open relation manager create modal from table action
FilamentFFilament / ❓┊help
3y ago