/**
  * Creates a new Fields model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Fields();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionTabular()
 {
     if (Yii::$app->request->isAjax) {
         $attributes = $_POST;
         $fields = new Fields();
         $fields->type = $attributes['input'];
         $fields->label = $attributes['label'];
         $fields->form_id = $attributes['formId'];
         $fields->group = isset($attributes['group']) ? $attributes['group'] : 0;
         $fields->options = [new Options()];
         if (!$fields->save()) {
             echo '0';
         }
         if ($fields->save()) {
             if ($fields->group == 0) {
                 $fields->group = $fields->id;
                 $fields->save();
             }
         }
     }
 }