© 2026 Hedgehog Software, LLC

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

Handling repeater items BelongsToMany select field manually

Background
Please find my current code attached.
I in my ProductResource, I have a repeater form field for the HasMany relationship between my Product model and my ProductSku model. Then in my repeater items, I have a
price
price
, a
sku
sku
, and a
attribute_values_id
attribute_values_id
field. The
attribute_values_id
attribute_values_id
is a select field with a BelongsToMany relationship between ProductSku and AttributeValue. This all works great, but I set the
attribute_values_id
attribute_values_id
from an
attribute_id
attribute_id
field outside of the repeater, meaning that I build all the necessary repeater items for a product, based on the selected
attribute_id
attribute_id
.

Why
Since I only use my
attribute_values_id
attribute_values_id
select field to store data in the pivot table between ProductSku and AttributeValue, and to set the ItemLabel, this field just causes the product creation process to be less intuitive. So I need to find a way to keep the existing functionality, without showing the
attribute_values_id
attribute_values_id
select field.

What I Have tried
Since everything works functionally, just being able to hide the select field would solve my problem. But if I add
->hidden()
->hidden()
to the select field, no pivot table data is stored in the database when I submit the form.
I also tried to use a Hidden field:
Forms\Components\Hidden::make('attribute_values_id'),
Forms\Components\Hidden::make('attribute_values_id'),
, and then use a
->mutateRelationshipDataBeforeCreateUsing()
->mutateRelationshipDataBeforeCreateUsing()
to somehow establish the BelongsToMany relationship, but I am not sure I can set relationship data for a ProductSku model that is not yet created.

What I need
I need to find a recommended approach for storing the BelongsToMany relationship between ProductSku and AttributeValue, without showing/using a BelongsToMany Select field inside the ProductSku Repeater field.
message.txt7.58KB
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Repeater belongsToMany pivot - empty
FilamentFFilament / ❓┊help
15mo ago
BelongsToMany relationship in Repeater
FilamentFFilament / ❓┊help
3y ago
select filter with belongsToMany
FilamentFFilament / ❓┊help
3y ago
Repeater : Grouping items
FilamentFFilament / ❓┊help
2y ago