/** * Creates a new Entity model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Entity(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * [actionCreate description] * @param string module * @param integer id * @return view [description] */ public function actionCreate($module = NULL, $id = NULL) { $model = new Entity(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (\Yii::$app->request->isAjax) { header('Content-type: application/json'); echo Json::encode(['status' => 'DONE', 'model' => $model]); exit; } else { return $this->redirect(['view', 'id' => $model->id]); } } else { if (!is_null($module) && !is_null($id)) { $model->mod_table = $module; $model->mod_id = $id; } return $this->renderAjax('@frenzelgmbh/cmentity/widgets/views/iviews/_form', ['model' => $model]); } }