Если я правильно понимаю, вышесказанное хорошо для редактирования, но не для добавления. Это решение должно работать в обеих ситуациях:
В ваших контроллерах или в /app/app_controller.php добавьте что-то вроде этого для добавления:
$insertID = $this->{$this->modelClass}->getLastInsertID();
$page = $this->{$this->modelClass}->getPageNumber($insertID, $this->paginate['limit']);
$this->redirect("/admin/{$controllerName}/index/page:{$page}");
... и что-то подобное для редактирования:
$page = $this->{$this->modelClass}->getPageNumber($id, $this->paginate['limit']);
$this->redirect("/admin/{$controllerName}/index/page:{$page}");
В вашем /app/app_model.php укажите следующее:
/**
* Work out which page a record is on, so the user can be redirected to
* the correct page. (Not necessarily the page she came from, as this
* could be a new record.)
*/
function getPageNumber($id, $rowsPerPage) {
$result = $this->find('list'); // id => name
$resultIDs = array_keys($result); // position - 1 => id
$resultPositions = array_flip($resultIDs); // id => position - 1
$position = $resultPositions[$id] + 1; // Find the row number of the record
$page = ceil($position / $rowsPerPage); // Find the page of that row number
return $page;
}
Надеюсь, это поможет!