コード例 #1
0
ファイル: TracksController.php プロジェクト: ranvirp/rdp
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Tracks();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Tracks'])) {
         $model->attributes = $_POST['Tracks'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #2
0
ファイル: EditorController.php プロジェクト: Kapodastr/grow
 /**
  *
  *  Показывает для создания и создает трек
  * 
  *  @param id 
  *  @return true
  *
  **/
 public function actionCreate_track($course = null)
 {
     if (!Yii::app()->my->access("edit")) {
         return false;
     }
     $track = new Tracks();
     $track->course = $course;
     if (isset($_REQUEST['Tracks'])) {
         foreach ($_REQUEST['Tracks'] as $key => $value) {
             $track->{$key} = $value;
         }
         if ($track->save()) {
             Yii::app()->notify->addErrors($track->getErrors());
             Yii::app()->notify->add("Новый трек успешно создан", "success");
             $this->redirect(array('/track/' . $track->id . '/edit'));
         } else {
             Yii::app()->notify->addErrors($track->getErrors());
             Yii::app()->notify->add("Не удалось создать трек", "danger");
         }
     }
     $this->render("track", array("track" => $track));
 }