I have this beforeSave method in my Student model which returns true or false. Instead of displaying a standard msg for all save errors in StudentsController(Your admission could not be saved. Please try again.), I want to display a different error message when beforeSave mtd of Student model returns false. How can I do that?
StudentsController
function add(){
if ($this->Student->saveAll($this->data)){
$this->Session->setFlash('Your child\'s admission has been received. We will send you an email shortly.');
}else{
$this->Session->setFlash(__('Your admission could not be saved. Please, try again.', true));
}
}
I suggest implementing validation rules and then calling:
Read up on data validation within CakePHP