This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
In my application, i have 2 users roles for the backend, lets Admin and Staff For the staff, i want a different configuration for the list (different column and different filter and different toolbar) and a different configuration for the form (less fields to display basically) Sure we can play with the permisions approach, but we can play also with our controller like this
public $formConfig = 'config_form.yaml';
public $listConfig = 'config_list.yaml';
then in the constructor
public function __construct()
{
if (UserHelper::isStaff()) {
$this->listConfig = 'config_list_staff.yaml';
$this->formConfig = 'config_form_staff.yaml';
}
parent::__construct();
BackendMenu::setContext('Acme', 'Demo', 'menu');
}
Last updated
Great solution.
I had a similar need, and approached it slightly different. Instead of linking a different config I chose to use formExtendFields in the controller and remove certain fields and add or re-add scoped fields as necessary based on permissions/user group.
wilirius15434 is doing it right, that's the correct way of manipulating forms. It's also mentioned that way in the docs.
chris10207 said:
In my application, i have 2 users roles for the backend, lets Admin and Staff For the staff, i want a different configuration for the list (different column and different filter and different toolbar) and a different configuration for the form (less fields to display basically) Sure we can play with the permisions approach, but we can play also with our controller like this
public $formConfig = 'config_form.yaml'; public $listConfig = 'config_list.yaml';
then in the constructor
public function __construct() { if (UserHelper::isStaff()) { $this->listConfig = 'config_list_staff.yaml'; $this->formConfig = 'config_form_staff.yaml'; } parent::__construct(); BackendMenu::setContext('Acme', 'Demo', 'menu'); }
I'm trying to do something similar i want it to depends on user permission to have recordUrl open either the update or the preview page
Could u please explain more the Userhelper::isStaff and how to make it please?
I tried to do it this way instead but it didnt work
if ($this->user->hasAccess('acme.name')) {
$this->listConfig = 'config_list_preview.yaml';
}
Rygar said:
chris10207 said:
In my application, i have 2 users roles for the backend, lets Admin and Staff For the staff, i want a different configuration for the list (different column and different filter and different toolbar) and a different configuration for the form (less fields to display basically) Sure we can play with the permisions approach, but we can play also with our controller like this
public $formConfig = 'config_form.yaml'; public $listConfig = 'config_list.yaml';
then in the constructor
public function __construct() { if (UserHelper::isStaff()) { $this->listConfig = 'config_list_staff.yaml'; $this->formConfig = 'config_form_staff.yaml'; } parent::__construct(); BackendMenu::setContext('Acme', 'Demo', 'menu'); }
I'm trying to do something similar i want it to depends on user permission to have recordUrl open either the update or the preview page
Could u please explain more the Userhelper::isStaff and how to make it please?
I tried to do it this way instead but it didnt work
if ($this->user->hasAccess('acme.name')) { $this->listConfig = 'config_list_preview.yaml'; }
Maybe you could just redirect to "preview" when you want a certain user to just see the record instead of update the record.
1-6 of 6