Reputation: 175
I need to access the data from a backend file by using a link in frontend.
Find the code below :
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->render('hello');
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
In the above code instead of hello, I need to pass to farmers page which is in the following location "C:\xampp\htdocs\f_project_yii\backend\views\farmer".
Upvotes: 0
Views: 177
Reputation: 640
When you are use a
$this->render('hello');
You must to have a ./protected/views/[Controller name in lowcase]/hello.php file
Upvotes: 0
Reputation: 23
One of solution to set absolute path to view like this
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->render('/farmer');
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
Upvotes: 1