public function actionCreate()
 {
     $ajax = Yii::app()->request->getParam('ajax');
     $model = new TcmnCommunication('form_scenario');
     //$model->scenario = $this->scenario;
     $this->performAjaxValidation($model, 'tcmn-communication-form');
     if (isset($_POST['TcmnCommunication'])) {
         $model->attributes = $_POST['TcmnCommunication'];
         try {
             if ($model->save()) {
                 if ($ajax) {
                     //echo 'saved';
                     Yii::app()->end();
                 }
                 if (isset($_GET['returnUrl'])) {
                     $this->redirect($_GET['returnUrl']);
                 } else {
                     $this->redirect(array('view', 'tcmn_id' => $model->tcmn_id));
                 }
             }
         } catch (Exception $e) {
             $model->addError('tcmn_id', $e->getMessage());
         }
     } elseif (isset($_GET['TcmnCommunication'])) {
         $model->attributes = $_GET['TcmnCommunication'];
     }
     if ($ajax) {
         $ttsk_id = Yii::app()->request->getPost('tcmn_ttsk_id');
         if (!empty($ttsk_id)) {
             $model->tcmn_ttsk_id = Yii::app()->request->getPost('tcmn_ttsk_id');
         }
         $ttsk_model = TtskTask::model()->findByPk($model->tcmn_ttsk_id);
         $cs = Yii::app()->clientScript;
         $cs->reset();
         $cs->scriptMap = array('jquery.js' => false, 'jquery.min.js' => false);
         echo $this->renderPartial('_form', array('model' => $model, 'ttsk_model' => $ttsk_model), true, true);
     } else {
         $this->render('_form', array('model' => $model));
     }
 }
 public function loadModel($id)
 {
     $m = TtskTask::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('D2tasksModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }