© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
9 replies
karim charfaoui

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;
        }
    }
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
            ]);
        }
    }
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
            ]);
        }
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Repeater and SpatieUpload Fill
FilamentFFilament / ❓┊help
3y ago
Manually fill simple repeater data value on edit
FilamentFFilament / ❓┊help
2y ago
testing repeater / fillForm / fill default item
FilamentFFilament / ❓┊help
2y ago
Fill repeater in custom form in modal
FilamentFFilament / ❓┊help
3y ago