Bet Way To Fill A Public Variable

I made a public variable $this->tagIds in my model Restaurant.

What is the best way to fill this variable with the id’s of the tags that belongs to the restaurant when i’m opening the update form (/restaurant/update/<id_restaurant>).

And what is the best place to put this code? in an After find, Controller or in the View?

Controller restaurant:

public function actionUpdate()













Model restaurant:


class Restaurant extends CActiveRecord


public $tagIds;

public function relations()


	return array(

		'city' => array(self::BELONGS_TO, 'City', 'city_id'),

		'tags' => array(self::MANY_MANY, 'Tag', 'restaurant_tag(restaurant_id, tag_id)'),