Before you call $this->User->validates() you must the data to model...do this $this->User->set($this->data)
On Apr 29, 2011 4:31 AM, "Sanfly" <[email protected]> wrote: Hi My cake version is 1.3.7 I'm just learning form validation and am having a few issues. Firstly, the manual is crap in that it doesn't tell you how to implement the validation in your model, and it doesn't tell you how to show the validation error messages in your view. Took a lot of digging to find all that! Anyway, on the the problem at hand. I thought I had this working on one field, went to implement for the rest of my fields and now it is always validating the form even when I have deliberately used inputs that should fail validation. I have stripped it back down to one field to try and get it working again In my model: user.php // VALIDATION var $validate = array( 'first_name' => 'notEmpty' ); In my controller: function add(){ if($this->data){ if ($this->User->validates($this->data)) { echo "does validate"; } else { //data doesn't validate echo "doesnt validate<br>"; $this->Session->setFlash('Please correct errors below.<br><br>'); } } } Can anyone see an obvious error that I have overlooked? BTW, the 'does validate' and 'doesn't validate' are just in there for me to see easily where my problems are occuring. Obviously wouldnt be there for production -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
