Using getStateUsing on an infolist component causes PHP to crash

When I add getStateUsing to a TextEntry, PHP exits.
Infolists\Components\TextEntry::make('name')->getStateUsing(fn ($state) => $state ?? ''),
Infolists\Components\TextEntry::make('name')->getStateUsing(fn ($state) => $state ?? ''),
Causes the following in the terminal from docker
laravel.test-1 | 2025-01-22 12:45:10,296 WARN exited: php (exit status 139; not expected)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 68 (terminated by SIGSEGV)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 69 (terminated by SIGTERM)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 70 (terminated by SIGSEGV)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 71 (terminated by SIGSEGV)
laravel.test-1 | 2025-01-22 12:45:11,303 INFO spawned: 'php' with pid 72
laravel.test-1 | 2025-01-22 12:45:10,296 WARN exited: php (exit status 139; not expected)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 68 (terminated by SIGSEGV)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 69 (terminated by SIGTERM)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 70 (terminated by SIGSEGV)
laravel.test-1 | 2025-01-22 12:45:10,296 INFO reaped unknown pid 71 (terminated by SIGSEGV)
laravel.test-1 | 2025-01-22 12:45:11,303 INFO spawned: 'php' with pid 72
That's a SIGSEGV failure. I'm using Laravel sail with no customisation
Solution:
yes, you need to use ->state() ```php TextEntry::make('name') ->state(fn (App $record): string => $record...)...
Jump to solution
9 Replies
LeandroFerreira
LeandroFerreira3mo ago
use formatStateUsing()
ollieread
olliereadOP3mo ago
That stops the error but does nothing There is no state, the name field doesn't exist on the model
LeandroFerreira
LeandroFerreira3mo ago
what are you trying to do?
ollieread
olliereadOP3mo ago
Provide the entries value
LeandroFerreira
LeandroFerreira3mo ago
inject $record ?
ollieread
olliereadOP3mo ago
For a form it's:
Forms\Components\TextInput::make('name')
->required()
->afterStateHydrated(function ($state, ?App $app, Forms\Set $set) {
if ($state === null && $app !== null) {
$set('name', $app->draft?->name);
}
}),
Forms\Components\TextInput::make('name')
->required()
->afterStateHydrated(function ($state, ?App $app, Forms\Set $set) {
if ($state === null && $app !== null) {
$set('name', $app->draft?->name);
}
}),
For a table it's:
Tables\Columns\TextColumn::make('name')
->getStateUsing(function (App $app) {
return $app->release?->name ?? $app->draft?->name ?? '--';
}),
Tables\Columns\TextColumn::make('name')
->getStateUsing(function (App $app) {
return $app->release?->name ?? $app->draft?->name ?? '--';
}),
I've added a dd() to the formatStateUsing call and it's never reached, I assume because the state is null And if I use getStateUsing PHP exits for some odd reason
Solution
LeandroFerreira
LeandroFerreira3mo ago
yes, you need to use ->state()
TextEntry::make('name')
->state(fn (App $record): string => $record...)
TextEntry::make('name')
->state(fn (App $record): string => $record...)
ollieread
olliereadOP3mo ago
Ah that has worked, thank you Sorry this is my first time using Filament and I keep tripping up on the inconsistencies
LeandroFerreira
LeandroFerreira3mo ago
welcome no problem

Did you find this page helpful?