Search code examples
phpsearchfilteryiicgridview

YII search is not working when renderPartial from another page


I have a problem with Yii search, which is working fine when accessing the page(Students/admin) directly, but if i renderPartial the same page from another page(Students/reg), Yii filter not search the result..

Thanks in advance


Solution

  • You have to create the model manually in your actionReg of the StudentsController. These values of the model will be used by the CGridView to set the filter.

    This might be something like this:

    public function actionReg($id) {
      $model = Students::model();
      $model->attributes = $_GET['Students'];
    
      $this->render('reg', array(
               'model' => $model,
            ));
    }
    

    If you have custom values in the model you have to set them also, for example

      $model->calculatedAverage = $_GET['Students']['calculatedAverage'];
    

    Then in your RegView you can pass this model to the table.

    To get an idea of how this works, try understanding what happens in the adminAction method.