/** * Creates a new Info model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Info(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('info-form', ['model' => $model]); } }
public function actionAddData() { $model = new Info(); if ($model->load(Yii::$app->request->post())) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model->created_by = Yii::$app->user->id; $model->created_date = date('Y-m-d H:i:s'); if ($model->save()) { $res = array('message' => 'Data Berhasil Di Simpan.', 'alert' => 'success', 'proses' => 'save', 'success' => true); } else { $res = array('message' => 'Data Gagal Di Simpan.', 'alert' => 'error', 'proses' => 'save', 'success' => false); } return $res; \Yii::$app->end(); } else { return $this->renderAjax('create', ['model' => $model]); } }
/** * Creates a new Info model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($id) { $this->layout = 'create_list'; $model = new Info(); if (Yii::$app->request->isPost) { $model->category_id = $id; $model->time = time(); $model->user_id = 1; } if ($model->load(Yii::$app->request->post()) && $model->save()) { // ) { $model->move_images(); return $this->redirect(['view', 'id' => $model->id]); } else { $view = Info::get_view($id); return $this->render('create', ['model' => $model, 'view' => $view, 'id' => $id]); } }