Repeater inside a relationship manager action

I am trying to implement a repeater inside of a modal form within a relationship manager for products.
My relationship structure is as follows:
Order -> Product -> Attachment -> RevenueLine.

I am trying to add the action to the ProductRelationManager so I can have a link inside the table of products in the order to add new attachments instead of opening the product edit page.

The repeater is nicely shown, and I can create new database records through this repeater

However after I clicked save and reopen the dialog it does not show the data. I can see in the docs that I need to fill the form but how can this be done for the repeater field? Also when I add a new attachment after I created the first few, it tries to delete all the attachments and then reinsert. This is not possible for my structure because every attachment has a relationship with revenueLines so it returns a foreign key constraint error
Screenshot_2023-12-15_at_11.48.59.png
Screenshot_2023-12-15_at_11.56.28.png
Solution
I found it, you indeed need to fill the form with the relationship data manually:
Action::make('attachments')
  ->icon('heroicon-o-link')
  ->fillForm(fn (Product $record): array => [
      'attachments' => $record->attachments
  ])
  ->form([
      Repeater::make('attachments')
          ->relationship('attachments')
          ->schema([
              FORM ELEMENTS
          ])
  ])
Was this page helpful?