/**
  * Creates a new UserText model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new UserText();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new UserText model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($type)
 {
     switch ($type) {
         case 'start':
             $isStart = true;
             $isEnd = false;
             break;
         case 'end':
             $isStart = false;
             $isEnd = true;
             break;
     }
     $model = new UserText();
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         if (!($model->load($post) && $model->validate())) {
             return $this->render('create', ['model' => $model, 'type' => $type]);
         }
         $models = [];
         $postData = Yii::$app->request->post()['UserText'];
         $groups = $postData['p_id'];
         $banks = $postData['b_id'];
         $l_id = $postData['l_id'];
         $t_id = $postData['t_id'];
         for ($ic = 0; $ic < count($groups); $ic++) {
             for ($jc = 0; $jc < count($banks); $jc++) {
                 $model = new UserText();
                 $post['UserText'] = ['p_id' => $groups[$ic], 'b_id' => $banks[$jc], 'l_id' => $l_id, 't_id' => $t_id, 'isStart' => $isStart ? 1 : '', 'isEnd' => $isEnd ? 1 : ''];
                 if ($model->load($post)) {
                     $models[] = $model;
                 }
             }
         }
         foreach ($models as $model) {
             $model->save();
         }
         return $this->redirect('/user-text/index/' . ($isStart ? 'start' : 'end'));
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('/user-text/index/' . ($isStart ? 'start' : 'end'));
     } else {
         return $this->render('create', ['model' => $model, 'type' => $type]);
     }
 }