Answer the question
In order to leave comments, you need to log in
Why is my parent view rendering?
installed the application https://github.com/dektrium/yii2-user inherited from the controller
in the config like this
'user' => [
'class' => 'dektrium\user\Module',
'adminPermission' => 'admin',
'modelMap' => [
'User' => 'app\models\User',
],
'controllerMap' => [
'admin' => 'app\controllers\AdminController'
],
],
use app\models\UsersSearch;
use dektrium\user\controllers\AdminController as BaseAdminController;
class AdminController extends BaseAdminController
{
public function actionIndex()
{
$searchModel = new UsersSearch();
$dataProvider = $searchModel->search(\Yii::$app->request->get());
return $this->render(\Yii::getAlias('index'), [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
}
/vendor/dektrium/yii2-user/views/admin/index.php
don’t tell me and how to correctly configure the render to the app/views/admin folder
Answer the question
In order to leave comments, you need to log in
And for your interest, look in the debug at the viewPath field of your child controller, or look at the source of the parent and find the viewPath there, most likely it is defined there.
Redefine the $viewPath field directly in the child controller:
class AdminController extends BaseAdminController
{
public $viewPath = ''; //ваш путь, если он может быть прописан напрямую
public __construct( /*внимательно - скопируйте сюда параметры родителя*/) {
$this->viewPath = Yii::getAlias('@app').'/views/admin'; //ваш путь, если нужно задать через алиас
parent::__construct( /* передайте все параметры без изменений */);
}
public function actionIndex()
{
$searchModel = new UsersSearch();
$dataProvider = $searchModel->search(\Yii::$app->request->get());
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
}
Why
and what is there?
try
or\Yii::getAlias('@app/views/admin')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question