when you create a user folder and new pages in it, they are not displayed on the site, instead of a display, it produces an error 404. And from the site folder, these pages are displayed without error. What could be the problem?

Here are two files created in the views / user folder. Kinds

main.php

['label' => 'Войти', 'url' => ['/user/login'], 'options' => ['class' => 'menu-item',]], ['label' => 'Регистрация', 'url' => ['/user/reg'], 'options' => ['class' => 'menu-item',]] 

SignupController.php

 <?php namespace app\controllers; use Yii; use app\models\RegForm; class SignupController extends \yii\web\Controller { public function actionReg() { $model = new RegForm(); return $this->render( 'reg', [ 'model' => $model ] ); } } 

SigninController.php

 <?php namespace app\controllers; use Yii; use app\models\LoginForm; class SigninController extends \yii\web\Controller { public function actionLogin() { $model = new LoginForm(); return $this->render( 'login', [ 'model' => $model ] ); } } 

    1 answer 1

    You need to create a UserController and write actions for it for those views you have created. Without a controller and actions, your views are just files. And if they are not rendered in any place of the site, then you will not open them.

    The simplest example:

     <?php namespace app\controllers; class UserController extends \yii\web\Controller { public function actionLogin() { return $this->render('login'); } } 

    PS Based on the code of your controllers, the views/signup/reg.php should be in the views/signup/reg.php and views/signin/login.php respectively. That is, the folder name inside the views corresponds to the beginning of the controller name.

    • updated the answer .. - Al Mr
    • Yes exactly. Thank you very much. Very much helped out) - GaLana