Cara Membuat Custom Search Yii

Hallo, selamat pagi.

Saya mau tanya soal custom search, saya ingin membuat form search semacam advanced search, saya sudah coba buat mirip seperti advanced search bawaan yii, tapi gak berfungsi. Mohon bantuannya master2. Thanks sebelumnya.

Source code nya sebagai berikut:

Model: VRates.php




<?php


/**

 * This is the model class for table "tRate".

 *

 * The followings are the available columns in table 'tRate':

 * @property integer $rate_id

 * @property integer $pol_id

 * @property integer $pod_id

 * @property string $cy_door

 * @property string $door_destinat

 * @property integer $liner_id

 * @property string $rate_category

 * @property string $cargo_type

 * @property string $effective_date

 * @property string $expired_date

 * @property string $remark

 */

class VUser extends CActiveRecord

{

	/**

	 * @return string the associated database table name

	 */

	/*public $liner_name;*/

	

	public function tableName()

	{

		return 'vUser';

		/*return 'tDetailRate';*/

	}


	/**

	 * @return array customized attribute labels (name=>label)

	 */

	public function attributeLabels()

	{

		return array(			


			'user_id' => 'User', 

			'email' => 'Email',

			'username' => 'Username', 

			'password' => 'password' , 

			'userlevel_id' => 'User Level ID', 

			'user_level' => 'User Level', 

		);

	}


	

	public function search()

	{

		// @todo Please modify the following code to remove attributes that should not be searched.


		$criteria=new CDbCriteria;


		$criteria->compare('user_id',$this->user_id);

		$criteria->compare('email',$this->email);

		$criteria->compare('username',$this->username);

		$criteria->compare('password',$this->password);

		$criteria->compare('userlevel_id',$this->userlevel_id);

		$criteria->compare('user_level',$this->user_level);




		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

	}


	/**

	 * Returns the static model of the specified AR class.

	 * Please note that you should have this exact method in all your CActiveRecord descendants!

	 * @param string $className active record class name.

	 * @return TRate the static model class

	 */

	public static function model($className=__CLASS__)

	{

		return parent::model($className);

	}

}




Controller: TRateController.php




public function actionIndex()

	{

		

		


		$model=new VRate('search');

		$model->unsetAttributes();  // clear any default values

		if(isset($_GET['VRate']))

			$model->attributes=$_GET['VRate'];	


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

			'model'=>$model,

		));

		

	}



View: index.php




<?php

/* @var $this TRateController */

/* @var $dataProvider CActiveDataProvider */


$this->breadcrumbs=array(

	'Rate',

);


$this->menu=array(

	array('label'=>'Create Rate', 'url'=>array('create')),

	array('label'=>'Manage Rate', 'url'=>array('admin')),

);

?>


<h1>Rates</h1>


<?php 


Yii::app()->clientScript->registerScript('search', "

$('.search-button').click(function(){

	$('.search-form').toggle();

	return false;

});

$('.search-form form').submit(function(){

	$('#trate-grid').yiiGridView('update', {

		data: $(this).serialize()

	});

	return false;

});

");


?>


<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>

<div class="search-form" id="ratesearch" >

<?php $this->renderPartial('_search',array(

	'model'=>$model,

)); ?>

</div>




<?php

$this->widget('ext.groupgridview.GroupGridView', array(

      'id' => 'vrate-grid',	      

      'itemsCssClass'=>'table table-bordered table-condensed',

      'dataProvider' => $model->search(),

      'extraRowColumns' => array('liner_name'),

      'extraRowPos' => 'above',

      'mergeColumns' => array('category','rate_id','pol_code','pod_code'), 

      'columns' => array(

      	array(  

      		'name'=>'pol_code',

 			'header'=>'',

 			'type'=>'raw', 

 			'value'=>'CHtml::link($data->pol_code." ~ ".$data->pod_code, array("/trate/$data->rate_id/"))',


		),

      	

        'category',

        'item',

        'currency',

        'ammountrate',

        

        

      ),

    ));

?>




view: _search.php




<?php

/* @var $this TRateController */

/* @var $model TRate */

/* @var $form CActiveForm */

?>


<div class="wide form">


<?php $form=$this->beginWidget('CActiveForm', array(

	'action'=>Yii::app()->createUrl($this->route),

	'method'=>'get',

)); ?>


	<div class="row">

		<?php echo $form->label($model,'rate_id'); ?>

		<?php echo $form->textField($model,'rate_id'); ?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'pol_id'); ?>

		<?php 

		echo $form->dropDownList($model,'pol_id',CHtml::listData(tPol::model()->findAll(), 'pol_id', 'pol_code','pol_name'),array('prompt'=>'Select POL'));


 		?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'pod_id'); ?>

		<?php 

		echo $form->dropDownList($model,'pod_id',CHtml::listData(tPod::model()->findAll(), 'pod_id', 'pod_code','pod_name'),array('prompt'=>'Select POD'));


 		?>

	</div>


	<!-- <div class="row">

		<?php echo $form->label($model,'cy_door'); ?>

		<?php echo $form->textField($model,'cy_door',array('size'=>30,'maxlength'=>30)); ?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'door_destinat'); ?>

		<?php echo $form->textArea($model,'door_destinat',array('rows'=>6, 'cols'=>50)); ?>

	</div> -->


	<div class="row">

		<?php echo $form->label($model,'liner_id'); ?>

		<?php 

		echo $form->dropDownList($model,'liner_id',CHtml::listData(tLiner::model()->findAll(), 'liner_id', 'liner_code','liner_name'),array('prompt'=>'Select LINER'));


 		?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'rate_category'); ?>

		<div class="compactRadioGroup">

            <?php

                echo $form->dropDownList($model, 'rate_category',

                    array(  'General' => 'General',

                            'All in' => 'All in',

                            'Super All in' => 'Super All in',

                            'SOC' => 'SOC'

                             

                            ) 

                    );

            ?>

        </div>

		<?php echo $form->error($model,'rate_category'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'cargo_type'); ?>

		<div class="compactRadioGroup">

            <?php

                echo $form->dropDownList($model, 'cargo_type',

                    array(  'DR' => 'DR',

                            'RF' => 'RF',

                            'DG' => 'DG',

                            'FR' => 'FR'

                             

                            ) 

                    );

            ?>

        </div>

		<?php echo $form->error($model,'cargo_type'); ?>

	</div>





	<!--- <div class="row">

		<?php echo $form->label($model,'rate_category'); ?>

		<?php echo $form->textField($model,'rate_category',array('size'=>30,'maxlength'=>30)); ?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'cargo_type'); ?>

		<?php echo $form->textField($model,'cargo_type',array('size'=>30,'maxlength'=>30)); ?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'effective_date'); ?>

		<?php echo $form->textField($model,'effective_date'); ?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'expired_date'); ?>

		<?php echo $form->textField($model,'expired_date'); ?>

	</div>


	<div class="row">

		<?php echo $form->label($model,'remark'); ?>

		<?php echo $form->textArea($model,'remark',array('rows'=>6, 'cols'=>50)); ?>

	</div> -->


	<div class="row_buttons">

		<?php echo CHtml::submitButton('Search'); ?>

	</div>


<?php $this->endWidget(); ?>


</div><!-- search-form -->