public function actionAdd() { $model = new Relation(); if (($data = Yii::app()->getRequest()->getPost('Relation')) !== null) { $model->setAttributes($data); if ($model->validate()) { if ($model->addRelation()) { $this->send(ERROR_NONE, 'success'); } } else { $this->error->capture($model); } } $this->render('add', array('relation' => $model)); }