© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
2 replies
Hache_raw

How to access $state inside a Repeater item ->collapsed()

Hello.

So I can access
$state
$state
to set the
->itemLabel()
->itemLabel()

But I don't know how to access
$state
$state
to set
->collapsed()
->collapsed()
to
true
true
of
false
false
depending on
$state['done']
$state['done']


This is my code:

public static function form(Form $form): Form
{
    return $form
        ->schema([

            // [...]

            Repeater::make('item')
                ->collapsible()
                ->relationship('items')
                ->schema([
                    TextInput::make('name')->required()->maxLength(255),
                    Toggle::make('done')->inline(false)->default(false),
                    RichEditor::make('description')->required(),
                ])
                ->itemLabel(fn (array $state): ?string => $state['name'] ?? null)
                ->collapsed(fn (array $state): bool => $state['done']), // THIS WON'T WORK. (I don't know how to access $state in collapsed)
        ]);

        // [...]
}
public static function form(Form $form): Form
{
    return $form
        ->schema([

            // [...]

            Repeater::make('item')
                ->collapsible()
                ->relationship('items')
                ->schema([
                    TextInput::make('name')->required()->maxLength(255),
                    Toggle::make('done')->inline(false)->default(false),
                    RichEditor::make('description')->required(),
                ])
                ->itemLabel(fn (array $state): ?string => $state['name'] ?? null)
                ->collapsed(fn (array $state): bool => $state['done']), // THIS WON'T WORK. (I don't know how to access $state in collapsed)
        ]);

        // [...]
}


Thanks.
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

Access to repeater item from inside
FilamentFFilament / ❓┊help
3y ago
how to access current state of repeater item?
FilamentFFilament / ❓┊help
2y ago
How to access the Repeater item?
FilamentFFilament / ❓┊help
3y ago
Show item preview when repeater item is collapsed
FilamentFFilament / ❓┊help
2y ago