/** * Creates a new Barang model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreatealias($id) { $model = new Barangalias(); $id = Barang::find()->where(['KD_BARANG' => $id])->one(); $nama = $id->NM_BARANG; $parent = $id->PARENT; if (Yii::$app->request->isAjax && $model->load($_POST)) { Yii::$app->response->format = 'json'; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { $model->CREATED_AT = date('Y-m-d'); $model->CREATED_BY = Yii::$app->user->identity->username; $model->save(); return $this->redirect(['index']); } else { return $this->renderAjax('_alias', ['model' => $model, 'id' => $id, 'nama' => $nama, 'parent' => $parent]); } }
/** * Creates a new Barangalias model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Barangalias(); if ($model->load(Yii::$app->request->post())) { $model->CREATED_AT = date('Y-m-d'); $model->CREATED_BY = Yii::$app->user->identity->username; $model->save(); return $this->redirect(['index']); } else { return $this->renderAjax('create', ['model' => $model]); } }