Mar 15, 2024
0
Level 1
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(),
Please or to participate in this conversation.