How can i filter a model inside my controller for CGridView and let user search it through the CGridView search?
If i filter like this
$model=new MyObject('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['MyObject']))
$model->attributes=$_GET['MyObject'];
$dataProvider = new CActiveDataProvider($model, array(
'criteria'=>array(
"join"=>"LEFT JOIN other_table ON other_table.field=field",
'condition'=>" other_field = ".$id." ",
),
));
and load the cgridview like this
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'corsi-grid',
'dataProvider'=>$corsi_frequentati[1], // $dataProvider
'filter'=>$corsi_frequentati[0], // $model
I can’t filter it later