次の作業シナリオをエミュレートしようとしています。Cakephp ブログ投稿の編集段階で、Prev
&Next
ボタンを追加する必要があります。を押すNext
と、現在のフォームが保存され、次のブログ投稿が編集モードで表示される必要があります。
私の編集フォームには次のものがあります。
//form create
echo $this->Html->link('Next',
array('controller' => 'posts', 'action' => 'next', $id, $nextId),
array('class' => 'btn', 'escape' => false)
);
//inputs
//form submit
のnext()
メソッドはPostsController
次のようになります。
<?php
// ...
public function next($id = null, $nextId = null) {
$this->Post->id = $id;
if (!$this->Post->exists()) {
throw new NotFoundException('Invalid id', 'info');
}
debug($this->request);
//if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Post->save($this->request->data)) {
$this->Session->setFlash('saved', 'ok');
$this->redirect(
array('controller'=>'posts',
'action' => 'edit',
$nextId));
} else {
$this->Session->setFlash('cant save', 'error');
}
//}
}
一見、request->data
空で、理由がわかりません。次に、問題は次のとおりです。私の論理は大丈夫ですか? このアプローチを使用して問題を解決できますか?
より良い解決策を共有できますか?