Esempio n. 1
0
 public function actionCreate2()
 {
     $model = new TblDosen();
     $model2 = new User();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['TblDosen'], $_POST['User'])) {
         $model->attributes = $_POST['TblDosen'];
         $model2->attributes = $_POST['User'];
         $valid = $model->validate();
         $valid = $model2->validate() && $valid;
         if ($valid) {
             if ($model->save()) {
                 $model2->NAMA_USER = $model->NAMA_DOSEN;
                 $model2->NIP_USER = $model->NIP_DOSEN;
                 $model2->USERNAME = $model->NIP_DOSEN;
                 $model2->PASSWORD = $model->NIP_DOSEN;
                 $model2->LEVEL = 2;
                 $model2->save(false);
                 $this->redirect(array('view', 'id' => $model->ID_DOSEN));
             }
         }
     }
     $this->render('create2', array('model' => $model, 'model2' => $model2));
 }