Reputation: 5039
I have the following code within a model
rules()
{
....
array('new_pass', 'length', 'min'=>6, 'max'=>64, 'tooShort'=>'Password is too short (minimum is 6 characters)'),
....
}
When I input a value that is between 1 and 5 chars long it errors saying it is too short. But if I leave it blank it updates? I'm not sure how to fix this or more importantly why it would let a blank value in.
I tried adding in a allowEmpty, that stopped it updating a password that was 0 length in chars but when I tried to then save the model with a 6+ length password it then error'd saying Password too short'
Any help greatly appreciated
Jonny
Upvotes: 3
Views: 4567
Reputation: 3435
As i understand its changepassword action so just add rule:
rules()
{...
array('new_pass','required','on'=>'youraction')
...}
But still 'allowEmpty'=>false'
must work for this.
Upvotes: 4