© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
Mansoor Khan

Save relationship with pivot attributes/columns

I need some help.

How can i conditionally fill the pivot attribute/column when creating a Model from Select field using the createOptionForm.

here is what i am trying.

// Relationship defined in Model
public function tags(): MorphToMany
{
    return $this->morphToMany(Tag::class, 'taggable')
        ->wherePivot('is_approved', false);
}

// Select input in a resource form.
Select::make('tags')
    ->relationship('tags', 'name')
    ->multiple()
    ->createOptionForm([
        TextInput::make('name'),
    ])
// Relationship defined in Model
public function tags(): MorphToMany
{
    return $this->morphToMany(Tag::class, 'taggable')
        ->wherePivot('is_approved', false);
}

// Select input in a resource form.
Select::make('tags')
    ->relationship('tags', 'name')
    ->multiple()
    ->createOptionForm([
        TextInput::make('name'),
    ])


When the relationship is saved, I need to set the is_approved column set to true/false based on a condition.

Thanks.
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

Creating with pivot attributes
FilamentFFilament / ❓┊help
2y ago
Relationship with pivot
FilamentFFilament / ❓┊help
3y ago
How use repeaters with MorphToMany relationship with pivot columns
FilamentFFilament / ❓┊help
2y ago
Attach Pivot attributes
FilamentFFilament / ❓┊help
2y ago