Created
July 17, 2013 22:09
-
-
Save cebe/6024994 to your computer and use it in GitHub Desktop.
Yii ActiveRecord Unique validator example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Example extends CActiveRecord | |
{ | |
// ... | |
public function rules() | |
{ | |
return array( | |
array( | |
'username', 'unique', 'on'=>'register', | |
'allowEmpty' => false, | |
'attributeName' => 'username', | |
'caseSensitive'=> false, | |
'className'=>'Example', | |
'message'=>'Sorry, this username has already been taken.', | |
), | |
); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment