© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
truthzeeker

Can't save relationship on create

I have a pivot table
category_comic
category_comic
for this relationship.

But can be saved on the edit operation.

Here are my files.

on resource
Forms\Components\Select::make('categories')
  ->relationship('categories', 'name')
  ->searchable()
  ->preload()
  ->multiple()
  ->required(),
Forms\Components\Select::make('categories')
  ->relationship('categories', 'name')
  ->searchable()
  ->preload()
  ->multiple()
  ->required(),


on Comic model (guarded)
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
   return $this->belongsToMany(Category::class);
}
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
   return $this->belongsToMany(Category::class);
}


on Category model (guarded)
 public function comic(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
   return $this->belongsToMany(Comic::class);
}
 public function comic(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
   return $this->belongsToMany(Comic::class);
}
Screenshot_08-19-2024_12.02.39.png
Solution
Nevermind, I overridden the
mount
mount
method on my Create page. So dumb. 😄
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

Save nested relationship on create
FilamentFFilament / ❓┊help
3y ago
Wizard Steps, Create Record doesn't save Relationship
FilamentFFilament / ❓┊help
3y ago
Can't receive relationship data on a form createAction
FilamentFFilament / ❓┊help
2y ago
How to save morphToMany relationship during create?
FilamentFFilament / ❓┊help
2y ago