Yii Framework Forum: admin page and search form - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

admin page and search form Rate Topic: -----

#1 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 11 February 2010 - 04:12 AM

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.
Posted Image
0

#2 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 11 February 2010 - 04:19 AM

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,
        ));
    }

Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users