I am unable to filter on any of my search fields. I have look at a lot of forum post and I seem to have everything I need to make filtering working, but it isn’t working. Below is my Model, Controller, and View:
Model: Evidences.php
...
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('created_by', 'required'),
array('created_by, modified_by', 'numerical', 'integerOnly'=>true),
array('title, summary, display_name', 'length', 'max'=>255),
array('description, created_at, modified_at', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, title, summary, description, created_at, modified_at, display_name, created_by, modified_by', 'safe', 'on'=>'search'),
);
}
...
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('title',$this->title,true);
$criteria->compare('summary',$this->summary,true);
$criteria->compare('description',$this->description,true);
$criteria->compare('created_at',$this->created_at,true);
$criteria->compare('modified_at',$this->modified_at,true);
$criteria->compare('display_name',$this->display_name,true);
$criteria->compare('created_by',$this->created_by);
$criteria->compare('modified_by',$this->modified_by);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Controller: EvidencesController.php
public function actionAdmin()
{
$model=new Evidences('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Evidences']))
$model->attributes=$_GET['Evidences'];
$this->render('admin',array(
'model'=>$model,
));
}
View: admin.php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'evidences-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'title',
'summary',
'description',
'created_at',
'modified_at',
/*
'display_name',
'created_by',
'modified_by',
*/
array(
'class'=>'CButtonColumn',
),
),
));
Please let me know what I am missing.