admin page and search form


(Dimis283) #1

I am using the admin page of the crud command and I create a search form.

My problem is that when I search something that have 2 or more pages of pagination when I push some page the critiria of the search form are not there, all the customers are there.

What is wrong.


(Dimis283) #2

I write this, it is the best solution?


public function actionIndex() {

        $model=new searchcustomer;

        if(isset($_POST['searchcustomer']) ) {

            $model->attributes=$_POST['searchcustomer'];

            $arr=array(

                    'pagination'=>array(

                            'pageSize'=>self::PAGE_SIZE,

                            'params'=>array('name'=>$model->CUSTOMER_NAME)

                    ),

                    'criteria'=>array(

                            'condition'=>'CUSTOMER_NAME  LIKE :tags',

                            'params'=>array(':tags'=>'%'.$model->CUSTOMER_NAME.'%'),


                    ),


            );

        }

        else if (isset ($_GET['name'])) {


            $arr=array(

                    'pagination'=>array(

                            'pageSize'=>self::PAGE_SIZE,

                            'params'=>array('name'=>$_GET['name'])

                    ),

                    'criteria'=>array(

                            'condition'=>'CUSTOMER_NAME  LIKE :tags',

                            'params'=>array(':tags'=>'%'.$_GET['name'].'%'),


                    ),

                    

            );

        }

        else

            $arr=array(

                    'pagination'=>array(

                            'pageSize'=>self::PAGE_SIZE,

                    ),

            );


        $dataProvider=new CActiveDataProvider('customers', $arr);

        $this->render('admin',array(

                'dataProvider'=>$dataProvider,

                'model'=>$model,

        ));

    }