Hello :) my user validation during "signup" is not working right:
<?php class User extends AppModel { var $name = 'User'; var $validate = array( 'username' => array( 'notEmpty' => array( 'rule' => array('minLength', 5), 'required' => true, 'allowEmpty' => false, 'message' => 'User name has to be at least 5 characters long' ), 'unique' => array( 'rule' => array('checkUnique', 'username'), 'message' => 'User name taken. Use another' ) ), 'password' => array( 'notEmpty' => array( 'rule' => array('minLength', 6), 'required' => true, 'allowEmpty' => false, 'message' => 'Password has to be at least 6 characters long' ), 'passwordSimilar' => array( 'rule' => 'checkPasswords', 'message' => 'Entered passwords does not match' ) ), 'email' => array( 'rule' => 'email', 'required' => true, 'allowEmpty' => false, 'message' => 'Please enter a valid email' ) ); } ?> I just want the username to be at least 5 characters long, the username has to be "unique" and both passwords has to be the same. But everytime I input the passwords the validation fails and I get "Entered passwords does not match". I used the tutorial in the book "CakePHP Application Development", but I can't figure out what I'm doing wrong. Please help me! Here is the users_controller.php: <?php class UsersController extends AppController { var $name= 'Users'; var $components = array('Auth'); function beforeFilter() { $this->Auth->allow('signup'); } function signup(){ if (!empty($this->data)) { if(isset($this->data['User']['password2'])) $this->data['User']['password2hashed'] = $this->Auth- >password($this->data['User']['password2']); $this->User->create(); if ($this->User->save($this->data)) { $this->Session->setFlash('Congratulations! You have signed up!'); $this->redirect(array('controller' => 'links', 'action'=>'index')); } else { $this->Session->setFlash('There was an error signing up. Please, try again.'); $this->data = null; } } } function checkUnique($data, $fieldName) { $valid = false; //if(isset($fieldName) && $this->hasField($fieldName)) $valid = $this->isUnique(array($fieldName => $data)); return $valid; } function checkPasswords($data) { if($data['password'] == $this->data['User']['password2hashed']) return true; return false; } } ?> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---