I got it working.

Dave

-----Original Message-----
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] 
Sent: October-19-09 2:16 PM
To: cake-php@googlegroups.com
Subject: Validation Help - All code Included


This is driving me crazy.
User Model:
 
var $validate = array(
        'username' => array(
                'usernameRule-1' => array(
                'rule' => array(
                                'notEmpty'),  
                'message' => 'Please choose a Username',
                        'required' => true,
                        'allowEmpty' => false,
                        'last' => true),
   
                'usernameRule-2' => array(
                'rule' => array(
                                'minLength', 8),  
                'message' => 'Username must be 8 characters or more',
                        'required' => true,
                        'allowEmpty' => false,
                        'last' => true)
          
       )
);

View:
<?php echo $form->create('User', array('controller' => 'user',  'action' =>
'registration'));?> <?php echo $form->input('User.username');?> <?php echo
$form->end('Submit');?> </div>

Controller:
function registration()
{
if (!empty($this->data)) {
            
                if ($this->User->validates()) {
                        $this->Session->setFlash('All valid.');
                                             
             } else {
                        $errors = $this->User->invalidFields();
                        debug($errors);
                  $this->Session->setFlash('There was an error signing up.
Please, try again.');
             }
}
}

I removed everything but 1 field.
No matter what I enter all I get is Please choose a Username. Enter 100
characters and same message.

$errors returns:
I have abcdefghijklmnop as a username, more than 8, not empty....does not
matter what I enter it always the same thing.

Array
(
    [username] => Please choose a Username
)

Please someone, anyone letmeknow what I am doing wrong?

Thanks

Dave




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to