Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fw-Ahr's avatar
Level 1

How can I prevent an Exception if the Select-Options in a relationship has a NULL value?

I use Filament Form with a SELECT and obtain the OPTION values from a relationship.

            Forms\Components\Select::make('project_id')
                ->required()
                ->relationship(name: 'project', titleAttribute: 'working_name')

There may be a case, that the 'working_name' has no value. In that case I get the ERROR message:

local.ERROR: Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string, null given, called in /var/www/html/storage/framework/views/1de72626fd42a8d8e29bb5f2fcead228.php on line 97 {"view":{"view":"/var/www/html/vendor/filament/forms/resources/views/components/select.blade.php","data":[]},"userId":1,"exception":"[object] (Spatie\LaravelIgnition\Exceptions\ViewException(code: 0): Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string, null given, called in /var/www/html/storage/framework/views/1de72626fd42a8d8e29bb5f2fcead228.php on line 97 at /var/www/html/vendor/filament/forms/src/Components/Concerns/CanDisableOptions.php:39).

How can I prevent that Error (except for forcing the 'working_name' to be not null in the table) ?

0 likes
0 replies

Please or to participate in this conversation.