disabledOn using user role

how disable a field in edit depending on user role ?
5 Replies
Tin
Tin2y ago
Hey there, You can use the ->disabled() method on the field in pair with callback function. Almost all methods available on the Fields can accept a callback. So what you can do is ->disabled(function(){ return auth()->user()->hasRole(...); })
Tin
Tin2y ago
Read this, it can help ALOT
knous
knousOP2y ago
I need to use the ->disableOn method on field in edit depending on user Role. i did : ->disabledOn(['edit',!auth()->user()->hasAnyRole(['super_admin', 'admin']) ]),
Dan Harrin
Dan Harrin2y ago
disabled(function (string $context): bool {
if (auth()->user()->hasAnyRole(['super_admin', 'admin'])) {
return false;
}

return $context === 'edit';
})
disabled(function (string $context): bool {
if (auth()->user()->hasAnyRole(['super_admin', 'admin'])) {
return false;
}

return $context === 'edit';
})
Want results from more Discord servers?
Add your server