public function setAttributesByPost($postData = array()) { parent::setAttributesByPost($postData); if (!$this->gameId) { $game = Game::model()->findByAttributes(array('title' => $this->gameTitle)); if ($game) { $this->gameId = $game->id; } } }