2amigos / yii2-usuario

Highly customizable and extensible user management, authentication, and authorization Yii2 extension
https://github.com/2amigos/yii2-usuario
Other
294 stars 142 forks source link

Cannot override login view (Error 500) #509

Closed amlopezalonso closed 1 year ago

amlopezalonso commented 1 year ago

What steps will reproduce the problem?

Basic template. Own login.php under views/user/security.

Have:

    'view' => [
         'theme' => [
             'pathMap' => [
                 '@Da/User/resources/views' => '@app/views/user',
             ],
         ],
     ],

under "components" in config/web.php.

What is the expected result?

Login form rendered.

What do you get instead?

Error 500:

yii\base\ViewNotFoundException: The view file does not exist: /myapp/vendor/2amigos/yii2-usuario/src/User/resources/views/_alert.php in /myapp/vendor/yiisoft/yii2/base/View.php:233
Stack trace:
#0 /myapp/vendor/yiisoft/yii2/base/View.php(156): yii\base\View->renderFile()
#1 /myapp/views/user/security/login.php(27): yii\base\View->render()
#2 /myapp/vendor/yiisoft/yii2/base/View.php(347): require('/usr/local/shar...')
#3 /myapp/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile()
#4 /myapp/vendor/yiisoft/yii2/base/View.php(156): yii\base\View->renderFile()
#5 /myapp/vendor/yiisoft/yii2/base/Controller.php(407): yii\base\View->render()
#6 /myapp/vendor/2amigos/yii2-usuario/src/User/Controller/SecurityController.php(172): yii\base\Controller->render()
#7 [internal function]: Da\User\Controller\SecurityController->actionLogin()
#8 /myapp/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#9 /myapp/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#10 /myapp/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#11/myapp/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction()
#12 /myapp/vendor/yiisoft/yii2/base/Application.php(384): yii\web\Application->handleRequest()
#13 /myapp/web/index.php(12): yii\base\Application->run()
#14 {main}
amlopezalonso commented 1 year ago

Found a workaround copying resources/views/shared/_alert.php one level up but I feel this should not have to be this way.

LATER: ah I noticed I have this in login.php:

<?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>

So I just changed to:

<?= $this->render('/shared/_alert', ['module' => Yii::$app->getModule('user')]) ?>

So now the problem is fixed. Sorry for the noise.