Ajax Validation of CJuiAutoComplete

I can’t work out how to do this.

So far I have:

		<div class="row">

			<?php echo $form->labelEx($model->cat,'name'); ?>


				$this->widget('zii.widgets.jui.CJuiAutoComplete', array(












			<?php echo $form->error($model->cat,'name', array("validateOnChange"=>true)); ?>


but it does not post back for ajax validation.

As you can see I’ve tried forcing the validation, but no joy.

Validation works fine on submit.

Ajax validation is working for other elements on the page.


The problem wasn’t CJuiAutoComplete but in the ajax validation code.

You have to validate like this if there is a related model attached.

$errors =  CActiveForm::validate(array($model, $model->related_model));

I’m having a similar problem. I try to validate a CJuiAutoComplete:

<?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(








)); ?>

Rule is as follows:

array('country', 'CountryValidator', 'message'=>'Bitte ein Land aus der Liste auswählen'),

where Validator looks like this


class CountryValidator extends CValidator


protected function validateAttribute($model,$attribute)




$model->addError($attribute, $this->message);




The validator works fine on submission of the form. But ajax validation is not working on this field at all.

Any ideas? Thanks a lot.

Solved it: if I donot set the name property


it works. Why is that?

Yii generate field names like somemodel[someattribute] which makes it possible to access all fields of the posted form from an array.