Ability to edit event via api by passing in array
This commit is contained in:
parent
78ef09705d
commit
2e3900d1c7
|
@ -72,19 +72,22 @@ class EventsController extends AppController {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function edit($id = null) {
|
public function edit($id = null) {
|
||||||
|
$this->Event->id = $id;
|
||||||
|
|
||||||
if (!$this->Event->exists($id)) {
|
if (!$this->Event->exists($id)) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
if ($this->request->is(array('post', 'put'))) {
|
|
||||||
if ($this->Event->save($this->request->data)) {
|
if ($this->Event->save($this->request->data)) {
|
||||||
return $this->flash(__('The event has been saved.'), array('action' => 'index'));
|
$message = 'Saved';
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$options = array('conditions' => array('Event.' . $this->Event->primaryKey => $id));
|
$message = 'Error';
|
||||||
$this->request->data = $this->Event->find('first', $options);
|
|
||||||
}
|
}
|
||||||
$monitors = $this->Event->Monitor->find('list');
|
|
||||||
$this->set(compact('monitors'));
|
$this->set(array(
|
||||||
|
'message' => $message,
|
||||||
|
'_serialize' => array('message')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue