Exemple #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Adverts();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Adverts'])) {
         $model->attributes = $_POST['Adverts'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemple #2
0
    /**
     * Displays the contact page
     * @param int $id User's id
     */
    public function actionCreate() {

        $model = new Adverts;

        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);

        if (isset($_POST['Adverts'])) {
            $model->attributes = $_POST['Adverts'];
            $model->user_id = Yii::app()->user->id;
            $model->created_at = date("Y-m-d H:i:s");
            $model->fields = serialize($_POST['Fields']);


            if ($model->save()) {
                $video = CUploadedFile::getInstances($model, 'youtube_id');
                //YoutubeHelper::processAdverts($model, $video);

                $images = CUploadedFile::getInstancesByName('images');
                // proceed if the images have been set
                ImagesHelper::processImages($model, $images);
                $this->redirect(array('adverts/view', 'id' => $model->id));
            }
        }

        $this->render('create', array(
            'model' => $model,
        ));
    }