модель
Код: Выделить всё
class books extends model
{
public $book_name;
public function rules()
{
return [
[['book_name'], 'string'],
];
}
public function attributeLabels()
{
return [
'book_name' => 'Название'
];
}
}
Код: Выделить всё
public function actionChild_index()
{
$books = new books();
$books ->book_name= '12311';
$dataProvider = new ActiveDataProvider(
['query' => $books , 'pagination' => ['pageSize' => 10]]);
return $this->render('test', ['dataProvider' => $dataProvider]);
}
вид
Код: Выделить всё
<div class="child-table">
<?php Pjax::begin(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'book_name',
'headerOptions' => ['style' => 'width:10%'],
]
],
]); ?>
<?php Pjax::end(); ?>
</div>
у меня ошибка:
The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.
Спасибо за помощь.