You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #6778 disable switch if user has no permission to edit (IndraGunawan)
This PR was merged into the 4.x branch.
Discussion
----------
disable switch if user has no permission to edit
This PR aims to make the switch completely disabled on index page if the edit action is disabled or user does not have enough permission to execute edit action
```php
public function configureFields(string $pageName): iterable
{
return [
BooleanField::new('isPublished'),
];
}
public function configureActions(Actions $actions): Actions
{
return $actions
->disable(Action::EDIT) // completely disable EDIT action
->setPermission(Action::EDIT, 'ROLE_ADMIN') // minimum role to execute EDIT action
;
}
```
current condition, the switch is toggleable when user clicks it then it creates an ajax request and gets 403 then switch disabled
---
I'm a little worried about reordering `BooleanConfigurator` constructor but if it does not reorder I get a deprecated message
```
Deprecated: Optional parameter $csrfTokenManager declared before required parameter $authChecker is implicitly treated as a required parameter
```
Commits
-------
ff1faca disable switch if user has no permission to edit
0 commit comments