I am currently using the framework yii2 , this one has a code generator called gii. When using the gii to generate the model, view and controller there is no problem, I create the 3 without problem, the real problem is when I want to see the result on the local server. The error that throws me is this:
Fatal error: Uncaught Error: Using $ this when not in object context in C: \ xampp \ htdocs \ basic \ views \ Computer \ index.php: 10 Stack trace: # 0 {main} thrown in C: \ xampp \ htdocs \ basic \ views \ Computer \ index.php on line 10
This is the action of my controller (IT IS CALLED "EquipoController"):
public function actionIndex()
{
$searchModel = new EquipoSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
This is my view and where the error is generated:
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\EquipoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Inventario'; //Esta es la linea 10
$this->params['breadcrumbs'][] = $this->title;
?>
Please, I need help to know why the error occurs and how to solve it, thanks in advance.