0
データウィジェットをpjuxで使用し、日付をソートする必要があります。私はこのhttp://www.yiiframework.com/doc-2.0/guide-output-data-widgets.htmlを使ってみました。しかし、フィルタリングに問題があります。 ビューでマイSiteController私の検索コントローラデータウィジェットのデータのフィルタリングYii2
$query->andFilterWhere([
'id' => $this->id,
'post_id' => $this->post_id,
'user_id' => $this->user_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'comment', $this->comment]);
return $dataProvider;
で
$PostView = Posts::findOne($id);
$model = new Comments();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->user_id = Yii::$app->user->getId();
$model->post_id = $id;
if ($model->save()):
$model = new Comments();
Yii::$app->session->setFlash('success', "OK");
else: Yii::$app->session->setFlash('error', "NOT");
Yii::error('Some error');
return $this->refresh();
endif;
} else {
$searchModel = new CommentsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('view', [
'PostView' => $PostView,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'model' => $model,
]);
}
を:私は'post_id' => '1',
フィルタリングに'post_id' => $this->post_id,
を変更した場合
<?php Pjax::begin(['id' => 'comments']) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'post_id',
'comment:ntext',
],
]); ?>
<?php Pjax::end() ?>
、取り組んでいます。助けてください。
私は試してみましたが、何も..私はこの状況で、var_dumpをデバッグで使用する方法を理解していませんか? –