/** * Displays edit event page. * * @return mixed */ public function actionEdit() { if (Yii::$app->request->get("eventname") == "") { throw new CHttpException(404, 'The specified post cannot be found.'); } $eventname = Yii::$app->request->get("eventname"); $list = Events::find()->where(['link' => $eventname]); if ($list->count() == 0) { throw new CHttpException(404, 'The specified post cannot be found.'); } if ($post = Yii::$app->request->post()) { $trans = new Transliterate(); $link = $trans->convert($post["name"]); $event = Events::find()->where(['id' => Yii::$app->request->post("id")])->one(); $event->name = $post["name"]; $event->geo_x = "50.4853"; //$post["geo_x"]; $event->geo_y = "30.5154"; //$post["geo_y"]; $event->geo_zoom = "21"; //$post["geo_zoom"]; $event->geo_name = $post["geo_name"]; $event->geo_google_maps_link = "https://www.google.com.ua/maps/search/kiev+geo+coo..."; //$post["geo_google_maps_link"]; $event->desc = $post["desc"]; $event->datetime = $post["date"] . " " . $post["time"]; $event->full_desc = $post["full_desc"]; $event->people_count = 0; $event->max_people_count = $post["max_people_count"]; $event->image = "asdcfvgh"; //''; $event->type = $post["type"]; $event->private = Yii::$app->request->post("private") == "on" ? 1 : 0; $event->link = $link; $event->FK_organizer_id = "1"; //''; $event->created = time(); $event->updated = time(); $event->save(false); $this->redirect("/events/" . $link); } return $this->render('edit', ['model' => $list->one()]); }