そのため、検証エラーは追加アクションには表示されますが、編集アクションには表示されません。ここに私のコントローラーからのスニペットがあります:
ここで、期待どおりの検証エラー メッセージが表示されます。
public function add() {
if ($this->request->is('post')) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved.'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please try again.'));
}
}
$this->set('clients', $this->User->Client->find('list'));
}
しかし、ここではありません:
public function edit($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved.'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
} else {
$this->request->data = $this->User->read(null, $id);
unset($this->request->data['User']['password']);
}
$this->set('user', $this->User->read());
$this->set('clients', $this->User->Client->find('list'));
}