public function actionCreate() { self::validateRequest(); $model = new CalendarEvent(); if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); $model->setEventDateTime(); if ($model->save()) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return CalendarEvent::getEventArray($model); } } $date = new \DateTime(Yii::$app->getRequest()->getQueryParam('date')); $model->all_day = 1; //para colocar dados corretos $model->setEventDateTime($date->format('Y-m-d'), $date->format('Y-m-d')); $model->calendar_id = \Yii::$app->user->identity->calendar_id; $model->description = ''; $model->location = ''; return json_encode($this->renderAjax('_create', ['model' => $model])); }