Hi Thanks very much it works like a charm. However, I have a question, please take a look at the code below:
'email' => array( 'notEmpty' => array( 'rule' => 'notEmpty', 'message' => 'This field cannot be blank', 'last' => true, ), 'email' => array( 'rule' => 'email', 'message' => 'That is not a valid email address.' ) ) It works with the same array key 'email' ? I tried, it works. May I know why ? On Dec 18, 5:22 pm, Ryan Schmidt <google-2...@ryandesign.com> wrote: > On Dec 18, 2010, at 03:01, John Maxim wrote: > > > > > 'username' => array( > > 'notEmpty' => array( > > 'rule' => 'notEmpty', > > 'message' => 'This field cannot be blank', > > 'last' => true > > ), > > 'username' => array( > > 'rule' => 'isUnique', > > 'message' => 'That username has already been taken.' > > ), > > 'username' => array('rule'=>'/^.{6,40}$/', > > 'message' => 'Minimum > > username 6 characters.') > > ), > > > The above code only enables "notEmpty" and Minimum characters '/^. > > {6,40}$/'. The rule for "isUnique" can't be triggered, can some share > > what needed to add somewhere in the code ? > > You used the same array key ("username") twice -- for both the second and > third rules -- so the third rule overwrote the second before CakePHP ever saw > it. Use a different key for each rule. Doesn't matter at all what it is, as > long as each is unique. > > Here's an example that should work. I also added "'last' => true" to each > rule (because I think CakePHP's default of last => false is silly), and I > reformatted the array so it's consistent, and thus easier to read. > > var $validate = array( > 'username' => array( > 'notEmpty' => array( > 'rule' => 'notEmpty', > 'message' => 'This field cannot be blank', > 'last' => true, > ), > 'uniqueCheck' => array( > 'rule' => 'isUnique', > 'message' => 'That username has already been taken.', > 'last' => true, > ), > 'lengthCheck' => array( > 'rule' => '/^.{6,40}$/', > 'message' => 'Minimum username 6 characters.', > 'last' => true, > ), > ), > ); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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