コード例 #1
0
ファイル: IbuController.php プロジェクト: robebeye/isims
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Ibu();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Ibu'])) {
         $model->attributes = $_POST['Ibu'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->nik_ibu));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Pendaftar();
     $model2 = new Keluarga();
     $model3 = new Ayah();
     $model4 = new Ibu();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pendaftar'])) {
         $model3->attributes = $_POST['Ayah'];
         $model4->attributes = $_POST['Ibu'];
         $model2->attributes = $_POST['Keluarga'];
         $model2->nik_ayah = $_POST['Ayah']['nik_ayah'];
         $model2->nik_ibu = $_POST['Ibu']['nik_ibu'];
         $model->attributes = $_POST['Pendaftar'];
         $model->no_kk = $_POST['Keluarga']['no_kk'];
         $valid = $model->validate();
         $valid = $model2->validate() && $valid;
         $valid = $model3->validate() && $valid;
         $valid = $model4->validate() && $valid;
         $savefoto;
         if (strlen(trim(CUploadedFile::getInstance($model, 'foto'))) > 0) {
             $savefoto = CUploadedFile::getInstance($model, 'foto');
             $model->foto = $model->no_pendaftaran . '-' . $model->nama_panggilan . '.' . $savefoto->extensionName;
         }
         if ($valid) {
             if ($model3->save() && $model4->save()) {
                 if ($model2->save()) {
                     if ($model->save()) {
                         if (strlen(trim($model->foto)) > 0) {
                             $savefoto->saveAs(Yii::app()->basePath . '/../images/' . $model->foto);
                         }
                         $this->redirect(array('view', 'id' => $model->no_pendaftaran));
                     }
                 }
             }
         }
     }
     $this->render('create', array('model' => $model, 'model2' => $model2, 'model3' => $model3, 'model4' => $model4));
 }