public function actionModalCreate() { $costbook = new Costbook(); $this->validateCreateModalPostData(); if (isset($_POST['Costbook']) && Yii::app()->request->isAjaxRequest) { $costbook = $this->attemptToSaveModelFromPost($costbook, null, false); if ($costbook->id > 0) { echo CJSON::encode(array('id' => $costbook->id, 'name' => $costbook->name)); Yii::app()->end(0, false); } else { throw new FailedToSaveModelException(); } } echo ModalEditAndDetailsControllerUtil::setAjaxModeAndRenderModalEditAndDetailsView($this, 'CostbookModalCreateView', $costbook, 'Edit'); }