我有动作第一个我将使用dataprovider a渲染listview。然后当用户搜索时我会将dataprovider a更新为dataprovider b。它是工作,但我点击查看页面上的下一页数据显示显示的数据属于dataProvider'a'不属于'b'。我不知道为什么。
这是控制器
$data = Post::get();
if(isset($_POST['btn_search']))
{
$a= $_POST['a'];
$b= $_POST['b'];
$c= $_POST['c'];
$data = Post::get($a, $b, $c);
}
return $this->render('search', array(
'data' => $data
));
这是观点:
<?php
\yii\widgets\Pjax::begin([
'enablePushState' => false,
]);
?>
<?=
ListView::widget([
'dataProvider' => $data,
'options' => [
'tag' => 'div',
'class' => 'panel-body list-group list-group-contacts',
'id' => 'list-search',
],
'itemView' => function ($model, $key, $index, $widget) {
return $this->render('_list_search',['model' => $model]);
// or just do some echo
// return $model->title . ' posted by ' . $model->author;
},
'itemOptions' => [
'tag' => false,
],
'pager' => [
'options' => [
'style' => 'margin-top: 10px; width: auto; margin-bottom: 10px; margin-right:5px',
'class' => 'pagination pager'
],
'nextPageLabel' => '<span class="glyphicon glyphicon-chevron-right"></span>',
'prevPageLabel' => '<span class="glyphicon glyphicon-chevron-left"></span>',
'maxButtonCount' => 5,
],
]);
?>
<?php \yii\widgets\Pjax::end() ?>
请帮帮我。非常感谢。