title: How to use yii2-user as sub-module inside another module
body: <p>I want to implement one module in an existing application.In that module I am trying to use yii2-user module.The yii2 docs say we can do that.</p>
  
  <pre><code>namespace app\modules\forum;
  
  class Module extends \yii\base\Module
  {
      public function init()
      {
          parent::init();
  
          $this-&gt;modules = [
              'admin' =&gt; [
                  // you should consider using a shorter namespace here!
                  'class' =&gt; 'app\modules\forum\modules\admin\Module',
              ],
          ];
      }
  }
  </code></pre>
  
  <p>I have module code as </p>
  
  <pre><code>namespace app\modules\cdas;
  
  class cdas extends \yii\base\Module
  {
      public $controllerNamespace = 'app\modules\cdas\controllers';
  
      public function init()
      {
          parent::init();
  
          // custom initialization code goes here
          $this-&gt;modules = [
             'user' =&gt; [
                  'class' =&gt; 'dektrium\user\Module',
                   'modelMap' =&gt; [
                      'Profile' =&gt; 'app\modules\cdas\models\users\Profile',
                      'User'=&gt;'aapp\modules\cdas\models\users\User',
                  ],  
                  'controllerMap' =&gt; [
                     'settings' =&gt; 'app\modules\cdas\controllers\user\SettingsController',
                     'admin' =&gt; 'app\modules\cdas\controllers\user\AdminController',
                     'role' =&gt; 'app\modules\cdas\controllers\user\RoleController',
                     'security' =&gt; 'app\modules\cdas\controllers\user\SecurityController',
              ],
          ];
      }
  }
  </code></pre>
  
  <p>But when I use the above methodology and try to access </p>
  
  <pre><code>http://localhost/&lt;app_name&gt;/web/cdas/user/security/login  
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>PHP Notice – yii\base\ErrorException
  
  Trying to get property of non-object
  in ....vendor\dektrium\yii2-user\views\_alert.php
  
  /**
   * @var $module dektrium\user\Module
   */
  
  
  
  &lt;?php if ($module-&gt;enableFlashMessages): ?&gt;
  </code></pre>
  
  <p>Please suggest proper way to implement the sub-module.</p>