fix: [API] Use restresponse to view an added event via /events/add

pull/4075/head
iglocska 2019-01-31 11:49:15 +01:00
parent 14e687e0bf
commit 66037a36c5
1 changed files with 2 additions and 5 deletions

View File

@ -1655,13 +1655,10 @@ class EventsController extends AppController
}
// REST users want to see the newly created event
$results = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $created_id));
$event = $results[0];
if (!empty($validationErrors)) {
$event['errors'] = $validationErrors;
$results[0]['errors'] = $validationErrors;
}
$this->set('event', $event);
$this->render('view');
return true;
return $this->RestResponse->viewData($results[0], $this->response->type());
} else {
// redirect to the view of the newly created event
$this->Flash->success(__('The event has been saved'));