Yii Form Filter/Validation Cheatsheet

Yii Form Filter/Validation Cheatsheet

Last updated:

Minimum Password length / Password compare

Filter/validation (assuming you've declared $username,$password and $password_confirm attributes):

    public function rules()
        return array(
                array('username, password, password_confirm', 'required'),
                array('password, password_confirm', 'length', 'min'=>6, 'max'=>40),
                array('password_confirm', 'compare', 'compareAttribute'=>'password','strict'=>TRUE),

Uniqueness Validator ##

Making sure a model attribute is unique in the DB:


This validates that no Instances of Class Person have a FirstName that is equal to this form's name attribute.