Skip to content

Instantly share code, notes, and snippets.

@soelen
Created October 13, 2016 09:43
Show Gist options
  • Save soelen/f0097df6bb7030e12a20d8f449f208f0 to your computer and use it in GitHub Desktop.
Save soelen/f0097df6bb7030e12a20d8f449f208f0 to your computer and use it in GitHub Desktop.
<?php
public function edit($id = null)
{
$page = $this->Pages->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$page = $this->Pages->patchEntity($page, $this->request->data);
if ($this->Pages->save($page)) {
$this->Flash->success(__('The page has been saved.'));
return $this->redirect(['action' => 'index']); //not redirecting to index
} else {
$this->Flash->error(__('The page could not be saved. Please, try again.'));
}
}
$parentPages = $this->Pages->ParentPages->find('list', ['limit' => 200]);
$this->set(compact('page', 'parentPages'));
$this->set('_serialize', ['page']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment