私が正しく理解していれば、上記は編集には問題ありませんが、追加することはできません。このソリューションは、両方の状況のために働く必要があります:あなたのコントローラや、あなたの/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}");
を...と編集のためにこのような何か:
この中に入れて、あなたの/app/app_model.phpで
$page = $this->{$this->modelClass}->getPageNumber($id, $this->paginate['limit']);
$this->redirect("/admin/{$controllerName}/index/page:{$page}");
、:
/**
* 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;
}
希望に役立ちます!
いくつかのコードが参考になります。 「編集」リンクにページ番号を入力する必要があります。 – slosd