コード例 #1
0
ファイル: UnitController.php プロジェクト: Sywooch/armin
 /**
  * Creates a new Unit model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Unit();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $soldiers = (new SoldierSearch())->selectOptions();
         return $this->render('create', ['model' => $model, 'soldiers' => $soldiers]);
     }
 }
コード例 #2
0
ファイル: UnitController.php プロジェクト: tqsq2005/Yii2adv
 /**
  * Creates a new Unit model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Unit();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return '单位(部门)[ ' . $model->unitname . ' ]添加成功!';
     } else {
         $parentId = Yii::$app->request->get('parentId');
         $parentId = $parentId == '0' ? '%' : $parentId;
         $model->upunitcode = $parentId;
         $model->upunitname = Yii::$app->request->get('parentName');
         $model->corpflag = strlen($parentId) > 1 ? '5' : '4';
         $model->unitcode = Unit::getMaxunitcode($parentId);
         return $this->renderAjax('create', ['model' => $model, 'isParent' => intval($this->findModel($parentId)->corpflag) < 5 ? "yes" : "no"]);
     }
 }