title: Overriding zfcuseradmin controller
body: <p>Im new to zf2 and im trying to override the zfcuseradmin/useradmincontroller
  but its not working. I've tried many things but can't get it to work
  This is also my first post here so excuse me if its not correct in any way.</p>
  
  <p>I've created a folder in the module folder called MyZfcUserAdmin
  I'm also using bjuauthorize, but don't know if thats important to know for you guys.
  The bootstrap is working, because the formfileds are added to my zfcuseradmin create form</p>
  
  <p>here is my code:</p>
  
  <p>module/MyzfcUserAdmin/config/module.config.php</p>
  
  <pre><code>return array( 
  'controllers' =&gt; array(
      'invokables' =&gt; array(
          'MyZfcUserAdmin' =&gt; 'MyZfcUserAdmin\Controller\MyZfcUserAdminController',
      ),
  ),
  
  );
  </code></pre>
  
  <p>module/MyzfcUserAdmin/src/MyzfcUserAdmin/Controller/MyZfcUserAdminController.php</p>
  
  <pre><code>&lt;?php
  namespace MyZfcUserAdmin\Controller;
  
  use ZfcUserAdmin\Controller\UserAdminController as BaseUserAdminController;
  
  class MyZfcUserAdminController extends BaseUserAdminController
  {
  
  public function createAction()
  {
      $result = parent::createAction();
      $form = $this-&gt;getServiceLocator()-&gt;get('zfcuseradmin_createuser_form');        
      $request = $this-&gt;getRequest();
  
      $service = $this-&gt;getAdminUserService();
  
      $messages = array();
      if ($request-&gt;isPost()) 
      {
  
          $data = $request-&gt;getPost()-&gt;toArray();
          $data['governance'] = 1;
  
  
          if ($service-&gt;createasd($data) ) 
          {
              $messages[] = array(
                  'type'    =&gt; 'success',
                  'icon'    =&gt; 'icon-ok-sign',
                  'message' =&gt; 'succes',
              );
              return $this-&gt;redirect()-&gt;toRoute('zfcadmin/zfcuseradmin/list');
          }
          else
          {
              $messages[] = array(
                  'type'    =&gt; 'error',
                  'icon'    =&gt; 'icon-remove-sign',
                  'message' =&gt; 'failed',
              );
  
          }
      }
  
      return array(
          'messages'  =&gt; $messages,
          'createUserForm' =&gt; $form
      );   
  }
  }
  </code></pre>
  
  <p>module/MyzfcUserAdmin/Module.php</p>
  
  <pre><code>&lt;?php
  
  namespace MyZfcUserAdmin;
  
  
  use BjyAuthorize\Provider\Role\ZendDb AS rolesDb;
  
  class Module
  {
      public $rights = array();
      public $governance = array();
  
      public function onBootstrap($e)
      {
  
          //get roles
          $serviceManager = $e-&gt;getTarget()-&gt;getServiceManager();
          $rolesdb = new rolesDb('', $serviceManager);
  
          $roles = $rolesdb-&gt;getRoles();
          $roleOptions = array('');
          foreach($roles AS $role)
          {
              $name = $role-&gt;getRoleId();
              if($name != 'guest')
                  $roleOptions[$name] = ucfirst($name);
          }
          $this-&gt;rights = array(
                  'name' =&gt; 'role',
                  'type' =&gt; 'Zend\Form\Element\Select',     
                  'attributes' =&gt; array(
                          'required' =&gt; 'required',
                  ),
                  'options' =&gt; array(
                          'label' =&gt; 'Rights',
                          'value_options' =&gt; $roleOptions,
                  )
              );   
  
          $this-&gt;governance = array(
                  'name' =&gt; 'governance',
                  'options' =&gt; array(
                          'label' =&gt; 'Governance',
                          'checkedValue'   =&gt; 1,
                          'uncheckedValue' =&gt; 0,
                  ),
                  'attributes' =&gt; array(
                          'type' =&gt; 'checkbox',
                  ),
              );   
  
  
          $app = $e-&gt;getParam('application');
          $em  = $app-&gt;getEventManager()-&gt;getSharedManager(); 
          $em-&gt;attach('ZfcUserAdmin\Form\CreateUser', 'init', function($e) {
              $form = $e-&gt;getTarget();
              //$form-&gt;add($this-&gt;rights);
              $form-&gt;add($this-&gt;governance);        
  
          });
          $em-&gt;attach('ZfcUserAdmin\Form\EditUser', 'init', function($e) {
              $form = $e-&gt;getTarget();
             // $form-&gt;add($this-&gt;rights);
              $form-&gt;add($this-&gt;governance);
          });
          $em-&gt;attach('ZfcUserAdmin\Form\EditUserFilter','init', function($e) {
              $filter = $e-&gt;getTarget();
              // Do what you please with the filter instance ($filter)
  
          });
  
      }
  
  
  
  
      public function getConfig()
      {
          return include __DIR__ . '/config/module.config.php';
      }
  
      public function getAutoloaderConfig()
      {
         return array(
              'Zend\Loader\StandardAutoloader' =&gt; array(
                  'namespaces' =&gt; array(
                      __NAMESPACE__ =&gt; __DIR__ . '/src/' . __NAMESPACE__,
                  ),
              ),
          );
      }
  
  
  }
  </code></pre>