/** * Load Societes model * @param integer $id * @return Societes * @throws CHttpException */ protected function loadModel($id = null) { if (null === $id) { $model = new Societe(); $ssid = $this->id . '_' . get_class($model); if (Yii::app()->session->offsetExists($ssid)) { $model->setAttributes(Yii::app()->session->offsetGet($ssid)); Yii::app()->session->offsetUnset($ssid); } } else { $model = Societe::model()->findByPk($id); } if ($model instanceof CModel) { $model->titleField = 'name'; return $model; } throw new CHttpException(404, 'Account not found'); }