"Empty" Password-Field passes all validation rules -> Why is that?


I have 5 validation rules for my password field (listed below)

When I update my password and leave the password-field completly blank

NO input error shows up… It passes the validation rules and gets saved in the DB.

When I check the DB the Password field actually is completly empty…

When I give input such as "ds$6" validation errors show up!

Why does an empty Password field pass the validation?!


			array('password','match', 'pattern'=>'#^[0-9A-Za-z]+$#', 'message'=>'Only the following characters are allowed: 0-9 A-Z a-z', 'on'=>'update' ),

			array('password','length','max'=>25, 'on'=>'update'),	// PW only 20 Chars

			array('password','length','min'=>6, 'on'=>'update'),	// PW min 6 Chars

			array('password','compare', 'on'=>'update'),		//  -> PASSWORD REPEAT

			array('password_repeat','safe', 'on'=>'update'), 	//  -> PASSWORD REPEAT


	public function actionUpdate($id)




		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);






				Yii::app()->user->setFlash('success',"Data saved!");  	








Add a required rule.

array('password, password_repeat', 'required', 'on' => 'create'),


maybe what you need is allowEmpty to be true

array('password, password_repeat', 'allowEmpty'=>true, 'on' => 'update'),

not tested yet though

Yes THX…

The ‘allowEmpty’ was the thing that was missing!