Just thought I’d leave a quick note to myself about validation errors not showing up when I use read() after a save() or saveAll(). The key is to use a conditional for the read() or I believe using find() work as well.
Won’t show validation errors:
if (!empty($this->data)) {
if ($this->User->saveAll($this->data, array('validate'=>'first'))) {
$this->Session->setFlash('User saved');
} else {
$this->Session->setFlash('User not saved.');
}
}
$this->data = $this->User->read(null, $id);
Will show validation errors:
if (!empty($this->data)) {
if ($this->User->saveAll($this->data, array('validate'=>'first'))) {
$this->Session->setFlash('User saved');
} else {
$this->Session->setFlash('User not saved.');
}
} else {
$this->data = $this->User->read(null, $id);
}