When you would restrict the display of a field or fieldset group on user credential. you must do the following
1. open the action class and add
public function preExecute() { parent::preExecute(); $this->configuration->setUser($this->getUser()); }
2. open the *GeneratorConfiguration class and add
protected $user; public function setUser($user) { $this->user = $user; } public function getUser() { return $this->user; } public function getEditDisplay() { $fieldsets = parent::getEditDisplay(); if (!$this->getUser()->hasCredential('admin')) { unset( $fieldsets['Auth'][2], // field $fieldsets['Rights'] // field group ); } return $fieldsets; } public function getNewDisplay() { ... // see getEditDisplay } public function getFormOptions() { return array('user' => $this->getUser()); }
3. last remove the fields from the form, open the *Form class and add
public function configure() { ... if (!$this->getOption('user')->hasCredential('admin')) { unset($this['is_super_admin'], $this['groups_list'], $this['permissions_list']); } ... }
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.