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

eliot59's avatar

Disabled with dehydrated but data wasn't saved to db (Filament v3)

If the current user role is teacher then while creating user, the roles field should be defaulted to student and selection be disabled. I use dehydrated() but the still wasn't saved to DB, and I tried it w/o it and still not working.

Select::make('roles')
                ->multiple()
                ->disabled(auth()->user()->hasRole('teacher'))
                    ->label('select_role')
                    ->relationship('roles', 'name')
                    ->default(function () {
                        if (auth()->user()->hasRole('teacher')) {
                            return [2];
                        }
                    })
                    ->dehydrated()
                    ->preload()
                    ->maxItems(1)
                    ->required(),
0 likes
0 replies

Please or to participate in this conversation.