예제 #1
0
 /**
  * Добавление отзыва
  * @return mixed
  */
 public function actionCreate()
 {
     $review = new Review();
     if ($review->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($review->validate()) {
             $review->uploadImage(Yii::$app->params['uploadPath']);
             $review->save(false);
             return 'success';
         } else {
             return $review->getFormattedError();
         }
     }
     $cities = ArrayHelper::map(City::find()->orderBy('name ASC')->asArray()->all(), 'id', 'name');
     $createdCity = new City();
     return $this->renderAjax('create', ['review' => $review, 'cities' => $cities, 'createdCity' => $createdCity]);
 }