Exemplo n.º 1
0
 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     $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]);
 }
Exemplo n.º 2
0
 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'company_id' => $model->company_id, 'user_id' => $model->user_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 3
0
 /**
  * Creates a new Contact model.
  * If no group or category exist will redirect to related creation page.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     $errorCode = 0;
     $categorie = Contact_category::getContact_category();
     if ($categorie == null) {
         $errorCode = 1;
     }
     $gruppi = Contact_group::getGruppi();
     if ($gruppi == null) {
         $errorCode = $errorCode + 2;
     }
     if ($errorCode > 0) {
         return $this->redirect(['create-group-or-category', 'errorCode' => $errorCode]);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         /* passage of parameter $categorie to 'create' view, and then to '_form' partial */
         return $this->render('create', ['model' => $model, 'categorie' => $categorie]);
     }
 }