Using $get to get the state of parent form fields in repeaters

Hi all Is there a way of getting the state of a parent form field in a closure in a repeater field? Eg this doesn't work:
TextInput::make('title')
->live(),

Repeater::make('members')
->schema([
TextInput::make('test')
->label(function (Get $get) {
return $get('title');
})
])
TextInput::make('title')
->live(),

Repeater::make('members')
->schema([
TextInput::make('test')
->label(function (Get $get) {
return $get('title');
})
])
6 Replies
LeandroFerreira
LeandroFerreira4mo ago
$get('../../title')
Povilas K
Povilas K4mo ago
Weird, worked for us multiple times, like in this demo:
Forms\Components\Checkbox::make('multi_language')
->live()
->columnSpanFull()
->dehydrated(false)
->formatStateUsing(fn (?Post $record) => (bool) $record?->title_translations)
->disabled(fn (?Post $record, $context) => (bool) $record?->title_translations && $context == 'edit'),
Forms\Components\Repeater::make('title_translations')
->hidden(fn (Forms\Get $get) => ! $get('multi_language'))
Forms\Components\Checkbox::make('multi_language')
->live()
->columnSpanFull()
->dehydrated(false)
->formatStateUsing(fn (?Post $record) => (bool) $record?->title_translations)
->disabled(fn (?Post $record, $context) => (bool) $record?->title_translations && $context == 'edit'),
Forms\Components\Repeater::make('title_translations')
->hidden(fn (Forms\Get $get) => ! $get('multi_language'))
https://laraveldaily.com/post/filament-repeater-set-values-manually-other-fields
binaryfire
binaryfire4mo ago
Have you tried it on a field inside the repeater's schema? It's working in fluent methods on the repeater itself. The problem is when trying to access parent field state in the repeater's sub-fields
Povilas K
Povilas K4mo ago
Hmm good point it's a different case then, then maybe @Leandro Ferreira is right here
binaryfire
binaryfire4mo ago
Nice thanks. I didn't see that when I checked the docs.