I have a model Person which has many Cars. In Person page I want to display all the cars he has … so I need to display CGridView on my Person page.
I did that like this
But, it seems the search wont work (it still not returning the correct result) and also for the buttons, it still using Person controller (I want to use Car controller for view, edit and delete)
How to change the default controller in CGridView ?
public function actionView($id)
{
$model = loadModel($id); // load the person
$carModel = New Car('search'); // container of search parameters for car
$carModel->unsetAttributes(); // clear all search parameters
$carModel->person_id = $model->id; // just search cars that belong to the person
if (isset($_GET['Car'])) { // check for inputs
$modelCar->attributes = $_GET['Car']; // set search parameters
}
$this->render('view', array(
'model' => $model,
'carModel' => $carModel,
));
}