Fill repeater on createView

I'm facing an issue while implementing an invoice creation . I'm using the Repeater component to display order items (commandeItems)
Here's a summary of what I have set up:
I have a Commande model with a hasMany relationship to CommandeItem.
I have an Invoice model with a hasMany relationship to CommandeItem
I'm using CreateInvoice, which extends Filament's CreateRecord to create a new invoice.
In CreateInvoice, I fetch a specific order with its associated articles (commandeItems) and attempt to pre-fill them in the form using mapCommandeItemsForForm().
Despite this, the Repeater for commandeItems stays empty when I open the form.
class CreateInvoice extends CreateRecord
{
    protected static string $resource = InvoiceResource::class;

    public $commande;

    public function mount(): void
    {
        parent::mount();

        $commandeId = request()->query('commande');
        if ($commandeId) {
            $this->commande = Commande::with('fournisseur', 'commandeItems')
                ->find($commandeId);
            $this->fillFormWithCommandeData();
        } else {
            $this->commande = null;
        }
    }

then i fill my form
protected function fillFormWithCommandeData(): void
    {
        if ($this->commande) {
            $this->form->fill([
                'commande_id' => $this->commande->id,
                'fournisseur_id' => $this->commande->fournisseur->id,
                'commandeItems' => $this->mapCommandeItemsForForm(),// return empty
            ]);
        }
    }
Was this page helpful?