© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•11mo ago•
1 reply
Mohamed Ayaou

Default value in Repeater items

I am trying to make my repeater items have a default value in one of its fields that increases for each new repeater item.

this is a code snippet:
Repeater::make('shipping_infos')
    ->itemLabel(function () {
        static $position = 1;
        return $position++;
    })
    ->schema([
        TextInput::make('reference')
            ->label(__('resources.shipments.fields.reference.label'))
            ->placeholder(__('resources.shipments.fields.reference.placeholder'))
            ->unique(Shipment::class)
            ->live()
            ->default(function () {  
                static $position = 1; 
                return 65000 + Shipment::count() + $position;
            })
            ->required(),
        // etc ...
    ])
Repeater::make('shipping_infos')
    ->itemLabel(function () {
        static $position = 1;
        return $position++;
    })
    ->schema([
        TextInput::make('reference')
            ->label(__('resources.shipments.fields.reference.label'))
            ->placeholder(__('resources.shipments.fields.reference.placeholder'))
            ->unique(Shipment::class)
            ->live()
            ->default(function () {  
                static $position = 1; 
                return 65000 + Shipment::count() + $position;
            })
            ->required(),
        // etc ...
    ])

the
itemLable()
itemLable()
is working and increasing for each new item fine, but that didn't work with the
default()
default()
method (I think since it is not a dynamic method?) and the reference field default value is the same between all the repeater items.
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 default items
FilamentFFilament / ❓┊help
3y ago
Repeater default value
FilamentFFilament / ❓┊help
10mo ago
Default repeater items not working
FilamentFFilament / ❓┊help
17mo ago
Repeater default items not working in cluster
FilamentFFilament / ❓┊help
2y ago