Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gedev's avatar
Level 1

Form builder many to many with repeater - don’t create the related record

Im using filament 3 admin panel, i have a resource for creating products. The product has a many to many relationship with the ingredients model and a pivot table

What i want to do is use a repeater on the product create and edit forms where multiple ingredients can be added by selecting an available ingredient in each repeater item from a select field.

I have reasons for this, but the problem i have is when i submit the product form to create the product the repeater element then tries to create the ingredients in the database as well, I don’t want this i only want it to create the relationship in the pivot table as the ingredients already exist

If I just use a multiple select field this works fine, it simply creates the relationsip between all selected ingredients and the new product but in my case i need this behaviour to happen with the repeater.

The reason i am using a repeater is that when each ingredient is added I use the state updated event to update other fields in the repeater item which are simply there for display purposes, so the only field that is actually relevant in each item is the select field which gives the value of the selected ingredient id, which needs to go into the pivot table

I haven't been able to find a way to do this so any advise would be great.

So in summary

  1. I have a product create form with form builder
  2. I have a repeater with a many to many relationship with ingredient model
  3. each repeater item only has one active field which is a select field to pick which ingredient from the ingredients table you want
  4. when the form is submitted the repeater tries to create new ingredients but I just want whatever is selected in the drop-down in each repeater item to go in the pivot table to link them to the products (like a multi select field does)
0 likes
1 reply
gedev's avatar
Level 1

Never mind I just found the answer in the documentation, I need a pivot model!

Please or to participate in this conversation.