Hello!
I have a problem trying to filter my results in my controller.
I got 2 tables called Alumno and Proyecto, these tables are related by alumno.proyecto_id and proyecto._id as suposed to.
Most topics in the forum use the admin view from the blog example. But i can't understand how to filter the results of $model->search() (as dataprovider to a Cgridview) to show only the "Alumno" whose "proyecto.year" equals some specific value.
Controller Action:
View:
Please help me to understand how to filter these data.
Greetings
I have a problem trying to filter my results in my controller.
I got 2 tables called Alumno and Proyecto, these tables are related by alumno.proyecto_id and proyecto._id as suposed to.
Most topics in the forum use the admin view from the blog example. But i can't understand how to filter the results of $model->search() (as dataprovider to a Cgridview) to show only the "Alumno" whose "proyecto.year" equals some specific value.
Controller Action:
$model = new Alumno('search');
$model->unsetAttributes();
if (isset($_GET['Alumno'])) {
$model->attributes = $_GET['Alumno'];
}
$this->render('lista', array(
'model' => $model,
'year'=>$year,
));
View:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'alumnos-grid',
'dataProvider'=>$dataProvider, //$model->search();
'filter'=>$model, //from the controller action
'columns'=>array(
'_id',
'nombre',
'apellido_paterno',
),
));
Please help me to understand how to filter these data.
Greetings