Inside my Model i have this code, this is partial code
protected function afterFind ()
{
$car= Car::model()->findAll("car_id = '{$this->model_id}'");
foreach($car as $cars) {
$val['car_name'][] = $cars->car_name;
$val['car_value'][] = $cars->car_value;
}
$this->car_arr = $val;
parent::afterFind();
}
How do i pass array to view? When i do something like this, there was an error output by YII saying
htmlspecialchars() expects parameter 1 to be string, array given
Yii
afterfind()method is overrided to Postprocess AR attributes.From the docs:
So it usually works like:
I am not sure what are you trying to do? but may be you want to automate some task (populating some array) after each find !!
In that case you can define a public array in your model:
$public car_arr = array();Then populate it in your
afterFind()and it will be accessible in the View.