/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Satuan(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Satuan'])) { $model->attributes = $_POST['Satuan']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->ID_SATUAN)); } } $this->render('create', array('model' => $model)); }
public function actionInsertSatuan() { if ($_POST) { $cek = DatabaseUmum::cekExist("satuan", "nama", $_POST['namaSt']); // cek menggunakan component DatabaseUmum if ($cek <= 0) { $SumberDana = new Satuan(); $SumberDana->nama = $_POST['namaSt']; $SumberDana->deskripsi = $_POST['deskripsiSt']; if ($SumberDana->save()) { $this->redirect(array('index')); } else { Yii::app()->user->setFlash('error', 'Maaf, simpan gagal'); $this->redirect(array('/errPage/errDB')); } } else { Yii::app()->user->setFlash('error', 'Maaf, simpan Satuan gagal. Data sudah ada'); $this->redirect(array('/errPage/errDB')); } } else { $this->actionIndex(); } }