예제 #1
0
 /**
  * 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]);
     }
 }
예제 #2
0
파일: Tour.php 프로젝트: phplego/testwork1
 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) {
         }
     }
 }