I have a search form. I would like to pagination the result.
$criteria
something like this:
if($_POST["tipus"] != 4){
$criteria->compare('t.tipus',$_POST["tipus"],true);
}
if($_POST["varos"] != 0){
$criteria->compare('`apartman`.`city`', $_POST["varos"], true);
}
if($_POST["ferohely"] != 0){
$criteria->compare('t.ferohely', $_POST["ferohely"], true);
}
My dataprovider:
$dataProvider= new CActiveDataProvider('UserAndApartman', array(
'criteria'=>$criteria,
'sort'=>array(
'defaultOrder'=>'t.id DESC',
),
'pagination'=>array(
'pageSize'=>2,
),
));}
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'kereses_eredmenyek_view',
));
So if i click on the second page, the post doesn't come again. How can i post it automatic?Can i get the $dataprovider
with pagination?
You're using $_POST, the $_POST['tipus'] and other data is lost when you're navigating to the next page, since you're not posting it to page 2, 3 etc. You can do two things:
Store the $_POST['tipus'] in a session, so the next page 'knows' what year it has to use. Store it in the url as a $_GET parameter, so instead of $_POST['tipus'] use $_GET['tipus']. When you navigate to page 2, the $_GET['tipus'] is available in the url on the next page. The last one is the easiest one i think, and that's how i usually use it. IF you use the get method, change the CActiveForm line to this:
<?php $this->beginWidget('CActiveForm', array(
'id'=>'fromid',
'method' => 'get'
)); ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.