コード例 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($type = 0, $parent_account_id = 0)
 {
     $model = new Accounts(['type' => (int) $type, 'parent_account_id' => (int) $parent_account_id]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (Yii::$app->request->post('ajax') !== null) {
             return \app\helpers\Response::send(200, $model);
         }
         //$model->deleteEavAttributes();
         //if (isset($_POST['AccounteavE']) && isset($_POST['AccounteavE'])) {
         //    $model->setEavAttributes(array_combine($_POST['AccounteavE'], $_POST['AccounteavV']));
         //}
         if (!$this->hasCallback()) {
             return $this->redirect(array('accounts/admin/' . $model->type));
         }
     }
     if (Yii::$app->request->post('ajax') !== null) {
         return \app\helpers\Response::send(501, $model->errors);
     }
     //$model->accType = Acctype::findOne((int) $type);
     //$model->type = $type;
     return $this->render('create', array('model' => $model));
 }