The ListView widget is used to display data from a data provider. Each data model is rendered using the specified view file.I am using this function to pass data to the view.
A typical usage is as follows:
use yii\widgets\ListView;
use yii\data\ActiveDataProvider;
function actionGet_record() {
$dataProvider = new ActiveDataProvider([
'query' => Post::find(),
'pagination' => [
'pageSize' => 20,
],
]);
echo ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_post',
]);
}
The _post view file could contain the following:
<?php
use yii\helpers\Html;
use yii\helpers\HtmlPurifier;
?>
<div class="post">
<h2><?= Html::encode($model->title) ?></h2>
<?= HtmlPurifier::process($model->text) ?>
</div>
Problem : Getting this error PHP Notice 'yii\base\ErrorException' with message 'Undefined variable: model'
How can I resolve it ?
Any help would be highly appreciated