This may just be a typo in your post but you're using $html->password() for a regular input. It should be <?php echo $html->input('User/profile', array('size' => 20)); ?>
I can't give any pointers for Cake 1.x but if you upgrade to the 1.2x branch you can do this: <?php echo $form->create('User', array('action' => 'add'); ?> <?php echo $form->input('User.username', array('size' => 20)); ?> <?php echo $form->input('User.profile', array('size' => 20)); ?> <?php echo $form->password('User.password', array('size' => 20)); ?> And then put something like the follwing in your User model. var $validate = array( 'username' => array( 'valid' => array( 'rule' => array('minLength', 1), 'required' => false, 'allowEmpty' => false, 'message' => '...' ), 'duplicate' => array( 'rule' => 'validateDuplicateUsername', 'on' => 'add', 'message' => '...' ) ), 'profile' => array( 'valid' => array( 'rule' => array('minLength', 1), 'required' => false, 'allowEmpty' => false, 'message' => '...' ), 'duplicate' => array( 'rule' => 'validateDuplicateProfile', 'on' => 'add', 'message' => '...' ) ), // other fields ); function validateDuplicateUsername($value) { // return false if not empty $res = $this->findByUsername($value); } On Sun, Apr 20, 2008 at 11:21 AM, Chez17 <[EMAIL PROTECTED]> wrote: > > I am having issues making sure that a field is unique. I am beginner > so please go easy on me. Right now, I am trying to create a simple > login system where the user name name and profile name have to be > unique. I have been cutting and pasting some stuff together and I > can't seem to get this to work out. Here is a sample of my 'create' > view: > > <label for="profile">Profile Name:</label> > <?php echo $html->password('User/profile', array('size' => 20)); ?> > <?php echo $html->tagErrorMsg('User/profile', 'You need to enter a > profile name.') ?> > > Now, here is my validation function: > > var $validate = array( > 'username' => VALID_NOT_EMPTY, > 'password' => VALID_NOT_EMPTY, > 'profile' => VALID_NOT_EMPTY > ); > When I tried use custom rules and try to make the validate array check > for uniqueness, my message gets lost. It will keep displaying the > 'You need to enter a profile name' error message, not the one I > specify in the validate array. So now I am trying to do some custom > validation, but I don't understand the find() function. I couldn't > find one concrete example of how to use it. I am too much of a > beginner to understand the API that they put out. > > I would like to know how to solve my problem both ways. How can I get > the message from the validate function to my view? Also, how can I > write a custom find() statement so I can check if a profile name is > already in the database? > > Thanks for your time, > Dave > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---