Yii Validation Tutorials

Insert, Update And Change Password In Yii Model

This tutorial will help you to understand “how to handle password field in yii”. I used scenario concept to change password. So the rule of models was configured based on scenario concept of yii framework.It was working fine for me.In Model.php Rules public function rules() { return array( array('username, password,confirmpassword', 'required', 'on'=>'insert'), array('username, password,confirmpassword', 'required', 'on'=>'updateuser'), array('password,confirmpassword', 'required', 'on'=>'changepassword'), array('password', 'compare', 'compareAttribute' =>'confirmpassword', 'on'=>'insert,changepassword'), array('password','passwordalphanumeric', 'on'=>'changepassword'), } public function passwordalphanumeric($attribute_name,$params){ […]... Read More »

Username Validation In Yii Model

From my sourcecode, I gave the information for username validation in yii framework.<?php class User extends CActiveRecord { public static function model($className=__CLASS__) { return parent::model($className); } public function tableName() { return 'tbl_user'; } public function rules() { array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u', 'message'=>'Username can contain only alphanumeric characters and hyphens(-).' ), array('username','unique'), } } ?>... Read More »

Email Validation In Yii Model

From my sourcecode, I gave the information for email validation in yii framework. <?php class User extends CActiveRecord { public static function model($className=__CLASS__) { return parent::model($className); } public function tableName() { return 'tbl_user'; } public function rules() { array('email','email'), array('email','unique'), //option } } ?>... Read More »

Password Validation In Yii Model

From my sourcecode, I gave the information for password validation in yii framework. I used password and confirm password validation. <?php class User extends CActiveRecord { public static function model($className=__CLASS__) { return parent::model($className); } public function tableName() { return 'tbl_user'; } public function rules() { array('password', 'compare', 'compareAttribute' => 'confirmpassword', 'on'=>'insert' ), } } ?>... Read More »