2

患者の「ビュー」ページで、ajax を使用して div を「doctors/add」に置き換えました。これで、患者ビュー ページに医師を追加できるようになりました。ただし、検証エラーが発生した場合は、患者ビュー ページから直接表示されます。検証メッセージを表示する「doctors/add」ページへ。
「追加」の入力フィールドに適切に検証メッセージを表示する現在のページにとどまります。

function add() {
    if (!empty($this->data)) {
        $this->Doctors->create();
        if ($this->Doctors->save($this->data)) {
            $this->Session->setFlash(__('The Doctor has been saved', true));
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The Doctor could not be saved. Please, try again.', true));
        }
    }

}

これは add() の $this->Session->setFlash によるものですか? ありがとう...!

4

2 に答える 2

4

これを試して

$this->redirect($this->here);
于 2014-07-06T16:08:22.527 に答える
0

これを試してもらえますか?

function add() {
if (!empty($this->data)) {
    $this->Doctors->create();
    if ($this->Doctors->save($this->data)) {
        $this->Session->setFlash(__('The Doctor has been saved', true));
        $this->redirect(array('action' => 'index'));
    } else {
        $this->Session->setFlash(__('The Doctor could not be saved. Please, try again.', true));


        $this->redirect(array('controller'=>'patient_controller_name', 'action' => 'view'));
    }
}

}
于 2012-05-19T04:14:03.353 に答える