患者の「ビュー」ページで、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 によるものですか? ありがとう...!