Sunday, February 24, 2013

Not seeing validation errors with saveAll

I have a list of User records that I'm saving at one time (the form is populated from an uploaded CSV).

Everything seems to be working fine, and my validation rules are being honoured, but one thing that's eluding me are the specific validation error messages.

I get the general validation error (if say, a field that is supposed to be unique is not), but I'm not getting an error on the specific field to let the user know what the actual problem is.

Is this a bug, or is there something wrong with my Code? Here's the action from my Controller (fwiw I'm passing the CSV data to this action from another action, hence the snippet at the beginning):

public function finalizeCsv() {
if ( isset($this->request->params['named']['csvData']) ) {
$csvData = unserialize( $this->request->params['named']['csvData'] );
} else {
$csvData = $this->request->data;
}
$this->set('users', $csvData);
if ($this->request->is('get')) {
$this->request->data = $csvData;
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->User->saveAll($this->request->data['User'])) {
$this->Session->setFlash('Users added!', 'default', array('class' => 'success'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('There were errors with your data.');
}
}
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: