/** * Creates a new Client model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Client(); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } elseif (!Yii::$app->request->isPost) { $model->load(Yii::$app->request->get()); } if (Yii::$app->request->isAjax) { return $this->renderAjax('_form', ['model' => $model]); } return $this->render('create', ['model' => $model]); }
/** * Creates a new Client model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Client(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'categories' => ClientCategory::find()->active()->all()]); } }
/** * Creates a new Client model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Client(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'categories' => ClientCategory::find()->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]); } }
/** * Creates a new Client model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Client(); $userModel = new User(); if (Yii::$app->request->isAjax && $userModel->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($userModel); } if ($model->load(Yii::$app->request->post()) && $userModel->load(Yii::$app->request->post())) { $arr = ['User' => $_POST['User'], 'Client' => $_POST['Client']]; $result = User::createUser($this->_roleId, $arr); if ($result) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'userModel' => $userModel]); } } else { return $this->render('create', ['model' => $model, 'userModel' => $userModel]); } }
public function actionCreate() { $model = new Client(); $userModel = new User(); //validate email unique if (Yii::$app->request->isAjax && $userModel->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($userModel); } // $group = Advisor::findGroupByAdvisor($this->user->id_extend); if ($model->load(Yii::$app->request->post())) { $user = User::createUser(Dict::USER_ROLE_CLIENT, ['User' => Yii::$app->request->post('User'), 'Client' => Yii::$app->request->post('Client')]); if ($user) { return $this->redirect(['index']); } } else { return $this->render('create', ['model' => $model, 'userModel' => $userModel]); } }