<?php yii\widgets\Pjax::begin(['id'=>'phoneDetail']);?> <?php $form = ActiveForm::begin(
['id'=>'queryPhone',
'method'=>'post',
'options'=>['data-pjax'=>'#phoneDetail']
]
) ?>
...
<?php ActiveForm::end() ?>
<?php yii\widgets\Pjax::end();?> 将ActionForm中的Option属性添加 'data-pjax' => ‘pjax ID’即可,我还傻傻的在submitButton中添加'data-pjax‘属性,看到 https://github.com/yiisoft/yii2/issues/5171这里我就懂了
附上 controller的对应action部分代码吧
return $this->renderAjax('index', [
'dataProvider' => $dataProvider,
'model'=>$data,
'from'=>$from,
]);