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, a sku, and a attribute_values_id field. The 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 from an 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.

Why
Since I only use my 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 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() 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'),, and then use a ->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.
Was this page helpful?