Hache_raw
Hache_raw
FFilament
Created by Hache_raw on 10/15/2024 in #❓┊help
How to access $state inside a Repeater item ->collapsed()
Hello. So I can access $state to set the ->itemLabel() But I don't know how to access $state to set ->collapsed() to true of false depending on $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.
3 replies