I am trying to create custom search for model, after performing the search i show it CGridView
The first page is fine. there is pager at the bottom, but when i click on pager to move to second (or last page) the grid shows empty result, but there are enoungh records to show in second page.
my action looks like this
public function actionSearch() {
$this->layout = '//layouts/column1';
$model = new SearchForm();
$model->unsetAttributes();
$result = NULL;
if (isset($_POST['SearchForm'])) {
$model->attributes = $_POST['SearchForm'];
if ($model->validate()) {
$r = new Document('search');
$result = $r->publicSearch($model);
}
}
$this->render('search', array('model' => $model, 'result' => $result));
}
where searchform is custom model for colecting user input
my document model has public search method like this
public function publicSearch(SearchForm $input) {
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->select = array('code', 'id', 'issue_date');
$criteria->with = array(
'customer' => array(
'select' => 'name',
),
'supplier' => array(
'select' => 'name',
),
'submitter' => array(
'select' => 'name',
),
);
$criteria->together = true;
$criteria->distinct = true;
$criteria->order = 't.id ASC';
$criteria->compare('t.code', $input->documentNumber, true);
$criteria->compare('customer.name', $input->name, true);
$criteria->compare('supplier.name', $input->name, true);
$criteria->compare('submitter.name', $input->name, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
// 'pagination' => array(
// 'pageSize' => 5,
// )
));
}
and my search view has cgridview like this
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'document-grid',
'showTableOnEmpty' => false,
// 'enablePagination' => false,
'dataProvider' => $result,
'summaryText' => '',
'columns' => array(
// 'code',
array(
'class'=>'CLinkColumn',
'labelExpression'=>'$data->code',
'urlExpression'=>'Yii::app()->createUrl("document/view",array("id"=>$data->id))',
'header'=>'Code'
),
'issue_date',
'customer.name',
'supplier.name',
'submitter.name',
),
));
?>
What am i missing?