0
典型的には、エラーを処理する一般的な方法は、そうようなリダイレクトない簡単である:CakePHPでのエラー処理が、ユーザーの投稿された値をフォームに戻していますか?
if ({something that is error}) {
$this->Session->setFlash(__('Error message'), true);
$this->redirect(array('controller' => 'some_controller', 'action' => 'some_action'));
}
しかし、私は方法のif ($this->request->is('post')) {
セクション中に発生する複数のチェックがあります。チェックのいずれかが失敗した場合は、残りの小切手を終了し、以前入力したすべての設定のフォームにユーザーを戻して、フォームにもう一度記入する必要はありません。私はこれをどのように実現するのでしょうか?
public function custom_method() {
// get some information here
if ($this->request->is('post')) {
// do_check
if (!do_check) {
// set flash
// log error
// don't run the rest of the checks - go to end of the if ($this->request->is('post'))
}
// do other check
if (!do_other_check) {
// set flash
// log error
// don't run the rest of the checks - go to end of the if ($this->request->is('post'))
}
// do database update
}
// do other stuff here
// then it goes to render view
}