/**
  * Creates a new TourField model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($tour_id)
 {
     $model = new TourField();
     $model->tour_id = $tour_id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         SortUtils::normalizeSort($model, ['tour_id' => $model->tour_id]);
         return $this->redirectToFieldList($model->tour_id);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     // Create fields for columns
     foreach (Booking::getTableSchema()->columnNames as $column) {
         $field = new TourField();
         $field->tour_id = $this->id;
         $field->name = $column;
         $field->title = "";
         try {
             $field->save(false);
         } catch (Exception $e) {
         }
     }
 }