I'm creating a user registration area and I am having difficulty doing
custom validation on the Password input field. I have the following
code in my controller:
__________________________________
/* Custom Password Validation */
if (empty ($this->data['User']['password'])) {
$this->User->invalidate ('password');
}
else if (empty ($this->data['User']['passwordc'])) {
$this->User->invalidate ('passwordc');
}
else if ($this->data['User']['password'] != $this->data['User']
['passwordc']) {
$this->User->invalidate ('password_comfirmation');
}
__________________________________
And I have the following code in my view:
__________________________________
<div class="form-item">
<?php echo $html->tagErrorMsg('User/password', 'Password is
required.'); ?>
<label for="UserPassword">Password:</label>
<?php echo $html->password ('User/password', array('size'=>'30',
'class'=>'input')); ?>
</div>
<div class="form-item">
<?php echo $html->tagErrorMsg('User/passwordc', 'You must confirm
your password.'); ?>
<label for="UserPasswordc">Confirm Password:</label>
<?php echo $html->password('User/passwordc', array('size'=>'30',
'class'=>'input'))?>
</div>
__________________________________
When I submit the form, it does do the password invalidation. The
problem is, the invalidation of the Password field never triggers an
error in validation. It will just happily save the blank password to
the database.
Any ideas why this would happen? I have a couple of other fields where
I'm doing custom validation and it works fine.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---