Username availability checker

I’m sure this is easy but can’t find it. What class handles the in page username availability checker like the one the forum has. An example would be nice to.

You mean the unique validation rule?

I got that part. I want to do exactly like the forum does green box around it if it is good without having to submit.

Did you check CActiveForm? It can be configured to do what you want.

Trying to get it working now.

Got it working kinda. I understand how to send errors but how do I tell it good or set the border color on the field.

public function unique(){

	$username = $this->username;

	if ($this->username != ""){




		else {

		$this->addError('username','Username already in use');		




protected function performAjaxValidation($model)


	if(isset($_POST['ajax']) && $_POST['ajax']==='EmployeeAddForm')


		   echo CActiveForm::validate($model);




<?php echo $form->labelEx($model,‘username’); ?>

<?php echo $form->textField($model,‘username’); ?>

<?php echo $form->error($model,‘username’); ?>

Nevermind… Need to do this stuff while i’m not tired so I can read better sorry.



Can you text the value of a input field using performAjaxValidation. Like if a enter last name Smith and it finds Bob for the first name it sets the input field firstname to Bob, or am i getting out side of built in functions now.

AFAIK not possible with ActiveForm.

Ok cool have the Java made for that already. Was just hoping yii had it by default.