Reputation: 13
yii\base\View::{closure}(): Argument #2 ($model) must be of type Libro, app\models\Libro given
in C:\xampp\htdocs\biblioteca\views\libro\index.php
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'titulo',
'imagen',
[
'class' => ActionColumn::className(),
* 'urlCreator' => function ($action, Libro $model, $key, $index, $column) {*
return Url::toRoute([$action, 'id' => $model->id]);
}
],
],
]); ?>
Upvotes: 1
Views: 3086
Reputation: 644
Include below line at the beginning of the script along with other use statements:
use app\models\Libro;
Upvotes: 0
Reputation: 8816
Change your closure from:
'urlCreator' => function ($action, Libro $model, $key, $index, $column) {*
return Url::toRoute([$action, 'id' => $model->id]);
}
Into:
'urlCreator' => function ($action, \app\models\Libro $model, $key, $index, $column) {*
return Url::toRoute([$action, 'id' => $model->id]);
}
In other words, use right class as type (
\app\models\Libro
instead ofLibro
).
Upvotes: 2