public function actionCreate() { $model = new tAccount(); // $this->performAjaxValidation($model); if (isset($_POST['tAccount'])) { $model->attributes = $_POST['tAccount']; $model->parent_id = 0; $model->haschild_id = 2; //must have children if ($model->save()) { //accmain $modelProperties0Add = new tAccountProperties(); $modelProperties0Add->parent_id = $model->id; $modelProperties0Add->mkey = "accmain_id"; $modelProperties0Add->mvalue = $_POST['tAccount']['accmain_id']; //must have children $modelProperties0Add->save(); //haschild $modelProperties1Add = new tAccountProperties(); $modelProperties1Add->parent_id = $model->id; $modelProperties1Add->mkey = "haschild_id"; $modelProperties1Add->mvalue = 2; //must have children $modelProperties1Add->save(); //currency $modelProperties2Add = new tAccountProperties(); $modelProperties2Add->parent_id = $model->id; $modelProperties2Add->mkey = "currency_id"; $modelProperties2Add->mvalue = $_POST['tAccount']['currency_id']; $modelProperties2Add->save(); //state $modelProperties3Add = new tAccountProperties(); $modelProperties3Add->parent_id = $model->id; $modelProperties3Add->mkey = "state_id"; $modelProperties3Add->mvalue = $_POST['tAccount']['state_id']; $modelProperties3Add->save(); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('createroot', array('model' => $model)); }